本文介绍了在JAXB MOXy中列出包装器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我声明一个List对象属性:
I am declaring a List object property with:
@XmlRootElement(namespace = "...")
@XmlType
public class Test {
private List<String> myList;
@XmlElementWrapper(name = "myListWrapper")
@XmlElement(name = "myList")
public List<String> getMyList() {
return myList;
}
}
当此类的实例带有空列表 myList
被编组,MOXy没有生成空包装 MyListWrapper
。但是,JAXB RI会这样做。生成的XML在使用RI时如下所示:
When an instance of this class with an empty list myList
is marshalled, MOXy is not generating an empty wrapper MyListWrapper
. However, JAXB RI would do it. The generated XML looks like this when using the RI:
<ns2:test xmlns:ns2="...">
<myListWrapper/>
</ns2:intensionalSet>
有没有办法用MOXy获得相同的结果?
Is there a way to obtain the same result with MOXy?
推荐答案
注意:我是领导和专家组。
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group.
这是MOXy中的一个错误JAXB的实现。您可以使用以下链接来跟踪此问题:
This is a bug in the MOXy implementation of JAXB. You can use the following link to track this issue:
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=363197
这篇关于在JAXB MOXy中列出包装器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!