开发者

Eliminating empty elements when marshalling with JAXB

开发者 https://www.devze.com 2022-12-13 14:16 出处:网络
Using JAXB (2) is it possible to ensure that null values are not marshalled as () empty elements.For instance

Using JAXB (2) is it possible to ensure that null values are not marshalled as () empty elements. For instance

@XmlRootElement(name = "root")
public class Root {
    @XmlElement(name = "name")
    protected String name;
}

Currently if name is null then 开发者_运维知识库I am marshalling

<root>
  <name/>
</root>

I would like to produce

<root>
</root>

instead.


i think u have missed something.. as u marshal it ,the string u are passing must not be null as with string null is also an string.. so in my opinion u must pass empty string rather than null.

0

精彩评论

暂无评论...
验证码 换一张
取 消