删除类=属性 [英] Remove class= attribute

查看:139
本文介绍了删除类=属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是简单的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

这篇关于删除类=属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆