[英]debug not working for rest method PUT using postman rest client
I have two Uri's 我有两个乌里
POST : http://localhost:8080/applications/2851/involved-parties/1/contacts POST: http:// localhost:8080 / applications / 2851 / involved-parties / 1 / contacts
PUT : http://localhost:8080/applications/2851/involved-parties/1/contacts 放置: http:// localhost:8080 / applications / 2851 / involved-parties / 1 / contacts
I am trying to debug methods,I have added breakpoint for both methods at starting, started server in debug mode. 我正在尝试调试方法,我在启动时都为这两种方法添加了断点,以调试模式启动了服务器。 while sending json request using postman rest client for POST method cursor stop you at break point at POST method.
使用POST方法游标的邮递员休息客户端发送JSON请求时,将您停在POST方法的断点处。 but same request for PUT method does not work your cursor does not stop you at break point its directly giving response back to client.
但是对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);
}
FYI : I am testing negative scenario for both method eg length for id is 4 if I pass the 5 length for id then it has to return exception 仅供参考:我正在测试两种方法的否定情况,例如id的长度为4如果我通过id的5长度,则它必须返回异常
Regards, 问候,
Normally with a PUT request to update, the particular resource URI should be known. 通常,通过更新的PUT请求,应该知道特定的资源URI。 So say the client makes a request to:
因此,说客户提出以下要求:
http://blah.com/applications/{applicationReferenceNumber}/involved-parties/{id}/contacts
Our service will look up the the id passsed. 我们的服务将查找传递的ID。 If it can't be found, we return a 404 status code, as the resource doesn't exist.
如果找不到该资源,我们将返回404状态代码,因为该资源不存在。 If it does exist, then we update the contacts for the application id provided in the request.
如果确实存在,那么我们将更新请求中提供的应用程序ID的联系人。 If you wanted to create a contacts, where the URI is not known, then POST would be correct, and you'd send a application id representation to:
如果您想创建一个不知道URI的联系人,则POST将是正确的,并且您将应用程序ID表示发送至:
http://blah.com/applications/{applicationReferenceNumber}/involved-parties/{id}/contacts
So basically if resource is available and we are doing put operation it will update directly on the server and also it is idempotent so evrytime you fire PUT request it will not do any other changes where as POST will create new resource every time and hence it will go through the code all the time. 因此,基本上,如果资源可用并且我们正在执行放置操作,它将直接在服务器上更新,并且它是幂等的,因此每次启动PUT请求时,evrytime都不会做任何其他更改,因为POST每次都会创建新资源,因此它将一直检查代码。
在Postman中,您可能需要通过POST发送数据,然后将_method字段添加为请求的一部分。
_method:put
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.