我要来回设置一个元素minOccurs="0"和nillable="true".
我正在阅读这篇文章,现在在我的WSDL中,我不确定使用它们是否值得.本文给出了一个很好的例子来表示你可能在其中散布空值的数组,因为这不能用于完成minOccurs="0".现在,我一直在使用的约定是,如果一个元素不是可选的,那么它就不是可用的.根据我的理解和我的问题所在的区别在于,通过将nillable属性应用于元素,我说你可以传入相当于NULL值的XSD?否则,没有nillable属性的元素必须在限制内放置一个值?
我想在 JSON 表示中将空对象编组为空。但是,现在,如果对象为空,我看不到 JSON 中的元素。
Example:
@XmlAccessType(FIELD)
@XmlType(name="foo" propOrder={"foo"}
class foo{
@XmlElement
private Integer foo;
private Integer another_foo;
..
getter()
setter()
}
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我将 foo 元素设置为 null。
但是 JSON 表示不显示响应中的元素。
响应看起来像这样
"foo" :{
"another_foo":something
}
Run Code Online (Sandbox Code Playgroud)
我尝试将 xml 元素属性设置为 nillable true。(@XmlElement(nillable=true)
这使得响应看起来像,
"foo" :{
"another_foo" : something
"foo":{nil :true}
}
Run Code Online (Sandbox Code Playgroud)
我希望它像,
"foo" :{
"another_foo":something
"foo" : null
}
Run Code Online (Sandbox Code Playgroud)
这里做错了什么?
能否请任何人解释一下以下声明的含义
@Column(nullable = false )
@XmlElement(required = true, nillable = true )
Run Code Online (Sandbox Code Playgroud)
这意味着 nullable 和 nillable 之间的区别?