);
输出结果:Customer[name=LEI,amount=99.99]
上例中,以下语句调用toUpperCase()方法
@Value("#{'lei'.toUpperCase()}")
private String name;
上例中,以下语句调用priceBean中的getSpecialPrice()方法
@Value("#{priceBean.getSpecialPrice()}")
private double amount;
2. Spring EL Method Invocation之XML
在XMl中配置如下,效果相同
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="customerBean" class="com.leidemo.el.Customer">
<property name="name" value="#{'lei'.toUpperCase()}"
/>
<property name="amount" value="#{priceBean.getSpecialPrice()}" />
</bean>
<bean id="priceBean" class="com.lei.demo.el.Price" />
</beans>