@XmlElementWrapper 用于解包集合 [英] @XmlElementWrapper for unwrapped collections

查看:72
本文介绍了@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>

了解更多信息

这篇关于@XmlElementWrapper 用于解包集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆