Context namespace exposes null-value attribute for property-placeholder element

Issue: SPR-13461
This commit is contained in:
Juergen Hoeller
2015-09-21 20:47:03 +02:00
parent b23c23279b
commit fbce18418a
6 changed files with 56 additions and 25 deletions

View File

@@ -1,18 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
<util:properties id="placeholderProps">
<prop key="foo">bar</prop>
<prop key="baz"></prop>
</util:properties>
<context:property-placeholder properties-ref="placeholderProps" ignore-unresolvable="true"/>
<context:property-placeholder properties-ref="placeholderProps" ignore-unresolvable="true" null-value=""/>
<bean id="string" class="java.lang.String">
<constructor-arg value="${bar}"/>
</bean>
<bean id="nullString" class="java.lang.String" factory-method="valueOf">
<constructor-arg type="java.lang.Object" value="${baz}"/>
</bean>
</beans>

View File

@@ -1,17 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
<util:properties id="placeholderProps">
<prop key="foo">bar</prop>
<prop key="bar">MYNULL</prop>
</util:properties>
<util:properties id="emptyProps"/>
<context:property-placeholder properties-ref="placeholderProps" order="2"/>
<context:property-placeholder properties-ref="placeholderProps" order="2" null-value="MYNULL"/>
<context:property-placeholder properties-ref="emptyProps" order="1" ignore-unresolvable="true"/>
@@ -21,4 +23,8 @@
<constructor-arg value="${foo}"/>
</bean>
<bean id="nullString" class="java.lang.String" factory-method="valueOf">
<constructor-arg type="java.lang.Object" value="${bar}"/>
</bean>
</beans>