jaxb:内联元素 [英] jaxb: inline elements
本文介绍了jaxb:内联元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
鉴于:
@XmlRootElement(name = "foo")
class Foo {
public Bar getBar() {...}
}
class Bar {
@XmlElement(name = "string")
public String getString() {return "hello";}
}
我如何注释所以XML将是:
How do I annotate so the XML will be:
<foo>
<string>hello</string>
</foo>
推荐答案
您可以利用<$ c $执行以下操作c> @XmlValue 注释。
Foo
@XmlRootElement
class Foo {
@XmlElement(name="string")
public Bar getBar() {...}
}
酒吧
class Bar {
@XmlValue
public String getString() {return "hello";}
}
更多信息
- http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html
这篇关于jaxb:内联元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文