【发布时间】:2010-07-28 16:17:35
【问题描述】:
我有这个类定义:
@XmlRootElement
public class RssRoot {
private String _version;
private String _xmlns_content;
@XmlAttribute()
public String get_version() {
return _version;
}
@XmlAttribute()
public String get_xmlns_content() {
return _xmlns_content;
}
public void set_version(String version) {
_version = version;
}
public void set_xmlns_content(String xmlnsContent) {
_xmlns_content = xmlnsContent;
}
public RssRoot() {
super();
this._version = "2.0";
this._xmlns_content = "http://purl.org/rss/1.0/modules/content/";
}
}
它会生成这个 xml:
<rssRoot xmlnsContent="http://purl.org/rss/1.0/modules/content/" version="2.0"/>
但是,我需要将 xmlnsContent 重命名为 xmlns:content,并将 rssRoot 重命名为 rss。我该怎么做?
我尝试在 getter 上方和属性声明附近使用 @XmlAttribute(name = "xmlns:content"),但没有运气。事情失败并显示此消息:
根异常堆栈跟踪: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException:IllegalAnno 计数 1 状态异常 类有两个同名的属性“_xmlns_content” 此问题与以下位置有关:RssRoot
我还能做什么?
【问题讨论】: