How to generate end tag for empty element in XML using JAXB

前端 未结 3 691
死守一世寂寞
死守一世寂寞 2021-01-18 00:37

I\'m generating XML using JAXB. But JAXB is generating an empty Tag closing it self. But my client want separate empty tag. I know both are equals but he is not agree with m

3条回答
  •  渐次进展
    2021-01-18 01:33

    Problem solved, To force a closing tag, just add an empty String as the value of this tag ! You can do it using @XmlValue :

    public class closedTag {
    
        @XmlValue
        private String content;
    
    
        public closedTag() {
            this.content = "";
        }
    
    }
    

提交回复
热议问题