我从这个link测试了简单的xml教程。我像这样更改了xml文件。
<example xmlns:ns1="http://www.blah.com/ns/a">
<a>
<b>
<x>abc</x>
<ns1:x>blah</ns1:x>
</b>
</a>
</example>
我将以下编码添加到Example7
类中。
@Path("a/b")
@Element(name = "x")
private String x_;
我得到了这个例外PersistenceException : Duplicate annotation of name 'x' on field 'x'
。我想知道如何克服这个例外。
感谢。
答案 0 :(得分:0)
您需要在班级x
中对您的字段Example7
进行注释,才能使用名称空间ns1
。
@Element
@Path("a/b")
@Namespace(reference="http://www.blah.com/ns/a", prefix="ns1")
private String x;