java 警告:一个 HTTP GET 方法,public javax.ws.rs.core.Response...抛出 org.codehaus.jettison.json.JSONException,不应使用任何实体

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25214921/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 07:35:54  来源:igfitidea点击:

WARNING: A HTTP GET method, public javax.ws.rs.core.Response... throws org.codehaus.jettison.json.JSONException, should not consume any entity

javaweb-servicesrestapiget

提问by Joie Tamayo

I have the following GET method, and it fails to send send back the result to the client.

我有以下 GET 方法,它无法将结果发送回客户端。

/*@GET here defines, this method will process HTTP GET requests. */
@GET
@Path("/test/{name}/{status}")
@Produces("application/json")
  public Response Name(@PathParam("name,status") String name, String status ) throws JSONException {
  String total = "100";
  .
  .
  .
  String result = "" + jsonObject;

  return Response.status(200).entity(result).build();
}

When I run it, I have the message below: WARNING: A HTTP GET method, public javax.ws.rs.core.Response... throws org.codehaus.jettison.json.JSONException, should not consume any entity.

当我运行它时,我收到以下消息:警告:一个 HTTP GET 方法,public javax.ws.rs.core.Response... throws org.codehaus.jettison.json.JSONException,不应消耗任何实体。

Does it have to do with the fact that I have two parameters ?

这与我有两个参数有关吗?

I already checked online but nothing relevant to my situation. Thanks in advance!

我已经在网上查过,但与我的情况无关。提前致谢!

回答by Joie Tamayo

I think I have found the issue...it should be like this:

我想我已经找到了问题……应该是这样的:

Name(@PathParam("name") String name, @PathParam("status") String status ) 

Thanks!

谢谢!