您的位置:首页 > 编程语言 > Java开发

Spring 给Bean属性注入null值

2016-06-06 14:40 387 查看
空字符串值可以使用
<value/>
元素可用来表示。例如:

<bean class="ExampleBean">
<property name="email"><value/></property>
</bean>


等同于Java代码:
exampleBean.setEmail("")


null值则可以使用
<null/>
元素可用来表示。例如:

<bean class="ExampleBean">
<property name="email"><null/></property>
</bean>


等同于Java代码:
exampleBean.setEmail(null)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: