spring EL表达式,null-safe表达式

时间:2023-03-08 17:33:42
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="saxophone" class="com.stono.sprtest.Saxophone"></bean>
<bean id="duke" class="com.stono.sprtest.Duke">
<property name="instrument">
<null />
</property>
<property name="name" value="#{saxophone.getName()}" />
<property name="name2" value="#{saxophone.name}" />
<property name="name3" value="#{saxophone.getName()?.toUpperCase()}" />
<property name="name4" value="#{saxophone.name?.toUpperCase()}" />
</bean>
</beans>