作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这个代码:
@ElementList(name = "Telefono")
@Namespace(reference = "efactura")
protected List<String> telefono;
它有一个祖先:
@Namespace(prefix = "ns2", reference = "efactura")
public class CFEDefType {
它生成:
<ns2:Telefono class="java.util.Arrays$ArrayList">
<string>12341234</string>
<string>0303456</string>
</ns2:Telefono>
当我期待时:
<ns2:Telefono class="java.util.Arrays$ArrayList">
<ns2:string>12341234</string>
<ns2:string>0303456</string>
</ns2:Telefono>
这有可能实现吗?
最佳答案
你试过这样做吗:
@Namespace(prefix = "ns2")
public final class Ns2String extends String {}
更新
由于 doppelganger 在评论中写道不可能扩展 String(这是最终的),所以他提出了这个(正确的)解决方案:
@Root(name="string")
@Namespace(reference = "efactura")
public static class Ns2String {
@Text
private String string = null;
public Ns2String(String string) {
this.string = string;
}
public String getString() {
return string;
}
public void setString(String string) {
this.string = string;
}
}
关于java - 简单的 XML 框架 : Strings in elementlist not having namespace prefix when serializing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27548475/
我是一名优秀的程序员,十分优秀!