问题描述
文档声明 @XmlElementWrapper 注释可用于未包装"或包装"集合.
The docs state the the @XmlElementWrapper annotation can be used for 'unwrapped' or 'wrapped' collections.
http://docs.oracle.com/javaee/5/api/javax/xml/bind/annotation/XmlElementWrapper.html
如何配置它以生成未包装的集合?
How do you configure it to produce an unwrapped collection?
推荐答案
如果你包含 @XmlElementWrapper 它将添加一个分组元素:
If you include @XmlElementWrapper it will add a grouping element:
@XmlElementWrapper @XmlElement(name="foo") public List<Foo> getFoos() { return foos; }
<root> <foos> <foo/> <foo/> </foos> </foo>
如果你省略它,那么它就不会.
and if you omit it, then it won't.
@XmlElement(name="foo") public List<Foo> getFoos() { return foos; }
<root> <foo/> <foo/> </foo>
更多信息
- http://blog.bdoughan.com/2012/12/jaxb-representing-null-and-empty.html