@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 用于未包装的集合
基础教程推荐
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 修改 void 函数的输入参数,然后读取 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
