java JAXB @XmlAttribute @XmlElement @XmlValue实例
@XmlAttribute 用法
@Data @XmlAccessorType(XmlAccessType.FIELD) public static class CouponOther{ @XmlElement(name = "Type") private String type; }
效果:
<Other> <Type>210</Type> </Other>
@XmlElement用法 :<Other Type="210"> </Other>
@Data @XmlAccessorType(XmlAccessType.FIELD) public static class CouponOther{ @XmlAttribute(name = "Type") private String type; }
效果:
<Other Type="210"> </Other>
@XmlValue用法:<Ref Code="couponid">TEST071909</Ref>
@Data @XmlAccessorType(XmlAccessType.FIELD) public static class CouponOther{ @XmlAttribute(name = "Type") private String type; @XmlElement private List<Ref> ref; @Data @XmlAccessorType(XmlAccessType.FIELD) public static class Ref{ @XmlAttribute(name = "Code") private String code; @XmlValue private String value; } }
效果:
<Other Type="210"> <Ref Code="OJ_SuperPNR_RPH">1</Ref> <Ref Code="couponid">TEST071909</Ref> </Other>
其他
标签:XML,java,String,private,static,互转,Data,XmlAttribute,XmlAccessorType From: https://www.cnblogs.com/chenze-Index/p/16940363.html