2
简单的任务,我需要产生这种XML:resteasy,jaxb - 如何生成一个集合/字符串列表?
<collection>
<name>bill</name>
<name>monica</name>
<collection>
,而不是这个(见下面的例子:19.6. Arrays and Collections of JAXB Objects):
<collection>
<customer><name>bill</name></customer>
<customer><name>monica</name></customer>
<collection>
简单收集处理字符串。所以问题是如何去除周围的customer
元素?我如何用RESTeasy和JAXB来做到这一点?
感谢很多答案。我已经忘了你的博客,我应该先看看那里:-)但是生活并不容易,我现在得到的异常是:'@XmlValue不允许在派生另一个类的类上。我试着在超类上使用'@ XmlTransient',但它不工作,有什么想法? –
@XmlTransient应该修复你的问题(http://blog.bdoughan.com/2011/06/ignoring-inheritance-with-xmltransient.html)。您的超类有任何映射到XML元素的属性吗?你知道你正在使用哪种JAXB实现吗(jaxbContextInstance.getClass()')的结果是什么? –
超类的'@ XmlTransient'修复了这个问题,它现在正如我所期望的那样工作。谢谢。 –