JAXB 无尽的数据结构,递归绑定? [英] JAXB endless data structure, recursive binding?
本文介绍了JAXB 无尽的数据结构,递归绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
s在开始一个项目之前,我想在这里做一个简短的提醒.
sBefore starting a project I wanted to get a short heads up here.
如果我有这样的结构:
<root>
<a>
<a>
<a>
<a>
<a/>
</a>
</a>
</a>
<a>
</a>
</a>
a
元素可以容纳 a
元素,而且这个无限深.
The a
element can hold a
elements and this endlessly deep.
我只是写一个 A 类然后给它一个 List 作为成员吗?那么 JAXB 会自动发挥作用吗?还是这种结构不可能?
Do I just write a class A and then give it a List as a member? JAXB does the magic automatically then? Or is this structure not possible?
推荐答案
是的,你可以拥有以下:
Yes you can have the following:
@XmlAccessorType(XmlAccessType.FIELD)
public class A {
private List<A> a;
}
还有你的 JAXB (JSR-222) 实现将正确编组它.
And your JAXB (JSR-222) implementation will marshal it correctly.
相关示例
这篇关于JAXB 无尽的数据结构,递归绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文