开发者

resteasy, jaxb - How to produce a collection/list of strings?

Simple task, I need to produce this XML:

<collection>
    <name>bill</name>
    <name>monica</name>
<collection>

instead of this (see following example: 19.6. Arrays and Collections of JAXB Objects):

<collection>
  开发者_JAVA技巧  <customer><name>bill</name></customer>
    <customer><name>monica</name></customer>
<collection>

Simple collection with strings. So the question is how to remove surrounding customer element? How can I do this with RESTeasy and JAXB?


On the Customer class map the name property with the @XmlValue annotation:

public class Customer {

    private String name;

    @XmlValue
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}

For More Information

  • http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜