【发布时间】:2016-09-02 00:29:32
【问题描述】:
我希望能够在我的回复中添加一个新标题。 我收到错误消息:
org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo 严重:找不到媒体 type=application/json、type=class java.util.ArrayList、genericType=class java.util.ArrayList 的 MessageBodyWriter。
我的代码如下:
@GET
@Path("/persons")
@Produces({ MediaType.APPLICATION_JSON })
public Response getPersons()
{
List<Person> persons = new ArrayList<Person>();
persons.add(new Person(1, "John Smith"));
persons.add(new Person(2, "Jane Smith"));
return Response.ok(persons).build();
}
当我使用“List”作为返回类型并返回“persons”时,返回成功,但是当我返回“Response”时出现错误。我该如何摆脱它?
【问题讨论】: