我使用的是简单的XML库: http://simple.sourceforge.net/home.php
I'm using simple xml library: http://simple.sourceforge.net/home.php
我有@ElementList标注了一个问题:如果我使用此批注是这样的:
I have a problem with @ElementList annotation: if I use this annotation like this:
@ElementList
protected List<Element> elements;
我的XML文件中有一个以上的属性:
My XML file has one more attribute:
<elements class="java.util.ArrayList">
如何删除属性类=...
?
在类
属性告诉简单而实施列表
您使用。如果它缺失,简单的将寻找一个合适的类本身。
The class
Attribute tells Simple which implementation of List
you use. If it's missing, Simple will look for a proper class itself.
一种解决方案是使用的ArrayList
,而不是列表
:
One solution is to use ArrayList
instead of List
:
@ElementList
protected ArrayList<Element> elements;
现在简单不会添加类属性。
Now Simple wont add the class-Attribute.
另一种方式:
@Path("elements")
@ElementList(inline=true)
protected List<Element> elements;
此内联的列表(没有的元素的-tag时),但把它变成一个新的元素的-tag
This inlines your List (no elements-Tag is used) but puts it into a "new" elements-Tag