开发者

Eliminating empty elements when marshalling with JAXB

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜