Tag: cxfrs

JAX-RS – 在apache CXF中没有根节点的JSON

如果我们在REST响应中返回集合对象,那么JSON(它将根元素节点作为集合对象名称 – 在这种情况下是雇员)将采用以下格式: { “employees”: [{ “id”: “1”, “name”: “employee name1”, “company”: “ABC Company” }, { “id”: “2”, “name”: “employee name2”, “company”: “XYZ Company” }] } 这是我们在应用程序上下文中的JsonProvider配置的一个截断器 @XmlRootElement(name=”emps”) public class EmpList{ private List employees; //setter and getter methods } @XmlRootElement(name=”emp”) public class Emp{ private int id; private Sting name; private String company; //setter and getter […]

没有为响应类ArrayList找到消息正文编写器

当我试图返回List时,它的抛出没有消息体编写器已被发现用于响应类ArrayList。 我的代码如下: @POST @Path(“/{scope}/{application}/tables”) @Produces(“application/xml”) public List getTableNames(@PathParam(“scope”) String scope, @PathParam(“application”) String application, Request request) { // For example, I am returning a list of String return new ArrayList(4); } 请帮帮我。 提前致谢