2

您好我需要修改现有的 Rest 接口。旧的 Rest 界面只取一个电话号码然后查找记录。电话号码曾经在表格中是唯一的。现在是电话和号码的组合(batchid)。所以我需要修改服务实现和调用它的客户端。这是旧控制器:

@RequestMapping(value="/{phone}", method = RequestMethod.GET)
        @ResponseBody
        public BatchDetail  findByPhone(@PathVariable String phone) {
            return batchDetailService.findByPhone(phone);

        }

这是旧客户访问它的方式:

private static final String URL_GET_BATCHDETAIL_PHONE = "http://localhost:8080/Web2Ivr/restful/batchdetail/{phone}";
batchdetail = restTemplate.getForObject(URL_GET_BATCHDETAIL_PHONE, BatchDetail.class, phone);           
batchdetail.setStatus("OK");
restTemplate.put(URL_TO_UPDATE_BATCHDETAIL, batchdetail, batchdetail.getId())

;

所以我的问题将是如何修改控制器和 restemplate 的客户端调用以支持两个变量,电话和号码(batchid),例如:

http://localhost:8080/Web2Ivr/restful/batchdetail/{batchid}/{phone}
4

1 回答 1

1
@RequestMapping(value="/{batchid}/{phone}", method = RequestMethod.GET)
@ResponseBody
public BatchDetail  findByPhone(@PathVariable String phone, @PathVariable String batchid) {
    return batchDetailService.findByPhone(phone);

}
于 2012-08-30T20:52:59.313 回答