我想在 Spring XML 配置文件中定义默认属性值。我希望这个默认值为 null
。
类似这样的:
...
<ctx:property-placeholder location="file://${configuration.location}"
ignore-unresolvable="true" order="2"
properties-ref="defaultConfiguration"/>
<util:properties id="defaultConfiguration">
<prop key="email.username" >
<null />
</prop>
<prop key="email.password">
<null />
</prop>
</util:properties>
...
这不起作用。是否可以在 Spring XML 配置中为属性定义 null
默认值?
最佳答案
这样使用Spring EL比较好
<property name="password" value="${email.password:#{null}}"/>
它检查是否指定了 email.password
并将其设置为 null
(不是 "null"
字符串)否则
关于spring - 在 Spring 中将默认属性值指定为 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16735141/