应该使用哪个注释标记来获取 JaxB 中的可重复标记内容?
Which annotation tag should use to get repeatable tag content in JaxB?
应该使用哪个注释标记将段落元素内容存储在字符串数组中?由于段落内部没有元素,即使创建单独的段落也无法存储内容class.
<letter>
<from>Hansel</from>
<to>Gretal</to>
<paragraphs>
<paragraph>
First paragraph text
</paragraph>
<paragraph>
Seconds paragraph text
</paragraph>
</paragraphs>
</letter>
我想你可以使用@XmlElementWrapper:
http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/annotation/XmlElementWrapper.html.
像这样:
@XmlElementWrapper(name = "paragraphs")
@XmlElement(name = "paragraph")
String[] paragraphs;
应该使用哪个注释标记将段落元素内容存储在字符串数组中?由于段落内部没有元素,即使创建单独的段落也无法存储内容class.
<letter>
<from>Hansel</from>
<to>Gretal</to>
<paragraphs>
<paragraph>
First paragraph text
</paragraph>
<paragraph>
Seconds paragraph text
</paragraph>
</paragraphs>
</letter>
我想你可以使用@XmlElementWrapper:
http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/annotation/XmlElementWrapper.html.
像这样:
@XmlElementWrapper(name = "paragraphs")
@XmlElement(name = "paragraph")
String[] paragraphs;