【发布时间】:2018-06-21 15:54:45
【问题描述】:
我有两个 Uri
发布:http://localhost:8080/applications/2851/involved-parties/1/contacts
输入:http://localhost:8080/applications/2851/involved-parties/1/contacts
我正在尝试调试方法,我在启动时为这两种方法添加了断点, 以调试模式启动服务器。在使用发送 json 请求时 POST 方法光标的邮递员休息客户端在断点处停止 POST 方法。但是对 PUT 方法的相同请求对您不起作用 光标不会在断点处阻止您,而是直接给出响应 回客户端。
@RequestMapping(value = "/applications/{applicationReferenceNumber}/involved-parties/{id}/contacts", method = RequestMethod.PUT)
@ResponseBody
public PutApplicationsResponse putContacts(@Valid @RequestBody final PutApplicationsRequest req,
final BindingResult bind, @PathVariable(value = "applicationReferenceNumber") final Long arn,
@PathVariable(value = "id") final Integer id, @RequestHeader final HttpHeaders httpHeaders,
final HttpServletRequest reqHTTP) throws ContactsException, SQLException, MethodArgumentNotValidException,
HttpMessageNotReadableException {
reqHTTP.setAttribute(ExceptionConstants.ARN, arn);
reqHTTP.setAttribute(ExceptionConstants.id, id);
objMp = new ObjectMapper();
if (bind.hasErrors()) {
throw new MethodArgumentNotValidException(null, bind);
}
仅供参考:我正在测试两种方法的负面情况,例如id 的长度是 4,如果我传递了 5 的 id 长度,那么它必须返回异常
问候,
【问题讨论】:
-
是的,我在postman中选择方法
-
请显示
PUT方法的服务器端代码
标签: java rest spring-mvc debugging postman