@XmlElementWrapper for unwrapped collections(@XmlElementWrapper 用于未包装的集合)
问题描述
文档声明 @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
这篇关于@XmlElementWrapper 用于未包装的集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:@XmlElementWrapper 用于未包装的集合
基础教程推荐
- 将 Windows 证书导入 Java 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- JPA惰性列表上的流 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
