我正在尝试使用 Restful cxf Web 服务调用从 MongoDB 检索文档列表。但我面临着
No message body writer has been found for response in Class ArrayList.
我关注了this tutorial 。在这里,他们在 CxfRestServiceImpl 类中返回员工对象作为响应。因此他们使用了@XMLElement(name = 'employee')
。
但现在我尝试从 MongoDB 返回文档列表作为 CxfRestServiceImpl
类中的响应。我需要做哪些改变才能克服这个错误?
最佳答案
如果我理解正确,那么您的代码中已经出现了此异常。相比之下,您最好将 List 答案包装在其他类中。
@XmlRootElement(name="DocumentList")
public class DocumentList {
@XmlElement
public List<Document> documentList;
}
关于java - 如何返回数组列表作为对 Restful CXF Web 服务调用的响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37741281/