简体   繁体   English

泽西Response.ok()不给200 OK

[英]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.

相关问题 如何正确使用Jersey的Response.ok(inputStream)方法 - How to use Jersey's Response.ok(inputStream) method properly Jersey可以生成List <T>但不能Response.ok(List <T>)。build()? - Jersey can produce List<T> but cannot Response.ok(List<T>).build()? Jersey HTTP响应200可以,但是返回内容错误(检查请求) - Jersey HTTP response 200 OK but returning content wrong (checking request) 使用jdom2.Document作为Response.ok()。entity(…)的参数 - Use jdom2.Document as argument to Response.ok().entity(…) 如何将Response.ok()。build()转换为json类型 - How to convert Response.ok().build() to json type rest / javax / jersey / grizzly:是否必须为POST请求返回OK(200)响应代码? - rest/javax/jersey/grizzly: is it mandatory to return OK (200) response code for POST requests? Jersey HTTP响应200可以,但是返回的内容错误(用户名/密码错误) - Jersey HTTP response 200 OK but returning content wrong (username/password incorrect) 响应 200 ok 并转到错误行 - Response 200 ok and goes to the error line REST API Response.ok(entity).build() 不显示文本 - REST API Response.ok(entity).build() doesn't show text JAX-RS Response.ok(Object).build不返回空字段(“”) - JAX-RS Response.ok(Object).build doesn't return empty field (“”)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM