Questions tagged «xml-binding»


8
JAXB和属性订购
我希望Java类中的序列化XML输出能够遵循Java类中属性的顺序。 似乎JAXB按字母顺序排序。 我可以通过@XmlType与propOrder一起使用并指定所有属性来覆盖此属性,但是我有一个包含许多属性的类,而这些属性尚未最终确定。 我读到,指定一个空的propOrder可以做到,但事实并非如此。 我的示例课: package test; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; @XmlRootElement //@XmlType(propOrder={"company", "scheme", "agreementNumber"}) @XmlType(propOrder={}) // makes no difference - still alphabetical in XML public class CustomerPlan2 { private String company; private String scheme; private String agreementNumber; @XmlElement(name="Company") public String getCompany() { return company; } public void …
69 java  jaxb  xml-binding 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.