我有一个返回对象数组列表的类 BookMain。我正在使用 REST 服务获取输出,但出现错误。
这是我的 BookMain 课程:
@GET
@Path("/get")
@Produces(MediaType.APPLICATION_XML)
public ArrayList<Object> addObjects() {
Book book = new Book();
book.setName("The Book");
book.setAuthor("Author");
BookStore bookstore = new BookStore();
bookstore.setName("The Bookstore");
bookstore.setLocation("UK");
ArrayList<Object> list = new ArrayList<Object>();
list.add(book);
list.add(bookstore);
return list;
}
这是我得到的错误:
11 Jul, 2013 3:36:52 PM com.sun.jersey.spi.container.ContainerResponse write
SEVERE: A message body writer for Java class java.util.ArrayList, and Java type java.util.ArrayList<java.lang.Object>, and MIME media type application/xml was not found 11 Jul, 2013 3:36:52 PM com.sun.jersey.spi.container.
ContainerResponse write SEVERE: The registered message body writers
compatible with the MIME media type are:application/xml ->
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$App
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$App
任何人都可以为我提供解决方案吗?