Java @XmlElementWrapper 用于解包集合
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16202583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
@XmlElementWrapper for unwrapped collections
提问by timmy
The docs state the the @XmlElementWrapperannotation can be used for 'unwrapped' or 'wrapped' collections.
文档说明@XmlElementWrapper注释可用于“未包装”或“包装”集合。
http://docs.oracle.com/javaee/5/api/javax/xml/bind/annotation/XmlElementWrapper.html
http://docs.oracle.com/javaee/5/api/javax/xml/bind/annotation/XmlElementWrapper.html
How do you configure it to produce an unwrapped collection?
您如何配置它以生成未包装的集合?
采纳答案by bdoughan
If you include @XmlElementWrapper
it will add a grouping element:
如果包含@XmlElementWrapper
它将添加一个分组元素:
@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>
For More Information
想要查询更多的信息