zoukankan      html  css  js  c++  java
  • java JAXB @XmlAttribute @XmlElement @XmlValue实例

     实体类

    @Data
    public static class CouponOther{  
        private String type;
    
      
        private List<Ref> ref;
    
        @Data   
        public static class Ref{
    	
    	private String code;
    
    	
    	private String value;
        }
    
    }
    

      

    @XmlAttribute 用法

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class CouponOther{
        @XmlElement(name = "Type")
        private String type;
    
    }
    

    x效果:

      

    <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>
    

      

  • 相关阅读:
    squid代理缓存服务
    部署网络存储ISCSI
    电子邮局系统
    使用DHCP动态管理主机地址
    vsftp -samba-autofs
    python初学 | 循环for while
    python初学 | 条件语句if
    python初学 | set
    python初学 | 字典dictionary
    python初学 | 元组tuple
  • 原文地址:https://www.cnblogs.com/achengmu/p/15045198.html
Copyright © 2011-2022 走看看