泽西通用实体不工作
我正在使用 Jersey 的 GenericEntity 以 json 形式返回列表。
但是我收到了异常
A message body writer for Java type, class java.util.Arrays$ArrayList, and MIME media type, application/xml, was not found
16-May-2011 11:16:31 com.sun.jersey.spi.container.ContainerResponse traceException
SEVERE: Mapped exception to response: 500 (Internal Server Error)....
,我知道这意味着 Jersey 未设置为正确映射到 json。
我需要在哪里向球衣提供更多信息。我没有使用 Maven。
破坏的代码是
List<String> list = Arrays.asList("test", "as");
return new GenericEntity<List<String>>(list) {};
I am using Jersey's GenericEntity to return a list as json.
However I'm getting the exception
A message body writer for Java type, class java.util.Arrays$ArrayList, and MIME media type, application/xml, was not found
16-May-2011 11:16:31 com.sun.jersey.spi.container.ContainerResponse traceException
SEVERE: Mapped exception to response: 500 (Internal Server Error)....
I know this means that Jersey is not setup to map to json properly.
Where do I need to give more information to jersey. I am not using Maven.
The code that breaks is
List<String> list = Arrays.asList("test", "as");
return new GenericEntity<List<String>>(list) {};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GenericEntity 应该以这种方式嵌入到 Response 中:
A GenericEntity is meant to be embedded in a Response that way: