Spring treats empty arguments for properties and the like as empty Strings
. The following XML-based configuration metadata snippet sets the email property to the empty String
value ("").
Spring对待属性中空的参数就像当做空的字符串一样.如下的基于XML配置元数据片段设置email属性为空的字符串("").
<bean class="ExampleBean"> <property name="email" value=""/> </bean>
The preceding example is equivalent to the following Java code:
前面的例子等同于下面的Java代码:
exampleBean.setEmail("");
The <null/>
element handles null
values. For example:
<null/>
元素处理 null
值.例如:
<bean class="ExampleBean"> <property name="email"> <null/> </property> </bean>
The above configuration is equivalent to the following Java code:
上面的配置等同于下面的Java代码:
exampleBean.setEmail(null);