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
精彩评论