[英]Jersey Response.ok() not giving 200 OK
This is the piece of code that I am using. 这是我正在使用的一段代码。
The ok(Object items) method is internally calling Jersey's Response.ok() method when items is null. 当items为null时,ok(Object items)方法在内部调用Jersey的Response.ok()方法。
MembershipRequestModel membershipRequest = null;
membershipRequest = communityService.addUserToCommunity(communityId, userId);
if(membershipRequest != null) {
// Add code 303 if returning membershiprequest
return seeOther( membershipRequest,
String.valueOf(membershipRequest.getId()),
MembershipRequestRestHandlerImpl.class);
} else {
return ok(null);
}
public Response ok() {
return Response.ok().build();
}
public Response ok(Object items) {
if ( items == null )
return ok();
return Response.ok().entity(items).build();
}
But, I am getting the response as 204 No Content which should have actually been 200 OK. 但是,我得到的响应为204 No Content,实际上应该是200 OK。 I have tried it using RESTClient firefox plugin and cURL command on CentOS. 我在CentOS上使用RESTClient firefox插件和cURL命令尝试过。
Please help. 请帮忙。
Thanks. 谢谢。
If there is no body, 204
will be returned. 如果没有身体,将返回204
。
all 2XX
are success. 所有2XX
都是成功的。
204
means success with no content (no entity body). 204
表示没有内容的成功(没有实体主体)。
www.w3.org/Protocols/rfc2616/rfc2616-sec10.html www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.