Jersey / Jaxb别名bean列表
我有一个界面
@Path("basePath") @Produces(MediaType.APPLICATION_XML) @Consumes(MediaType.APPLICATION_XML) public interface SomeService { @GET @Path("list") public List getItems() throws WebApplicationException; }
还有一个豆子
@XmlRootElement(name = "item") @XmlAccessorType(XmlAccessType.FIELD) public class ItemBean { @XmlElement(name = "name") private String someName; @XmlElement(name = "description") private String desc20Char; .....
如果我提出请求,我的回复是
foo bar ....etc....
除了itemBeans标签之外,所有这些都很好。 如何将其重命名为项目? 我尝试将@XmlElement(name =“items”)添加到接口的方法,实现类的方法和返回参数。 我错过了什么吗? 谢谢
@XmlRootElement(name = "itemBeans") @XmlAccessorType(XmlAccessType.FIELD) public class ItemBeans { @XmlElementWrapper(name = "items") @XmlElement(name = "item") private List beans; public ItemBeans(List beans) { this.beans = beans; } public ItemBeans() { } }
WS
@GET @Path("list") public ItemBeans getItems() throws WebApplicationException; }
响应
-
first second -
first1 second1