Spel注入
<h1>Spring的属性注入-spel注入</h1>
<pre><code>1.Spel:spring expression language ,spring 表达式语言 对于依赖注入进行简化
2.语法:#{表达式}
3.<bean id="" value="#{表达式}">
Spel 表达式语言
语法:#{}
#{'hello'}
#{beanID} 使用字符串
#{beanId.content.toUpperCase()}:使用制定名属性并使用方法
#{T(java.lang.Math).PI}:使用静态字段或方法</code></pre>
<pre><code class="language-java"> <bean id="Person" class="net.spring.ioc.methodConstruct.setterPerson" >
<property name="name" value="spicy"/>
<property name="age" value="1" />
</bean>
<bean id="price" class="net.spring.ioc.methodConstruct.GoodsNumber" />
<bean id="con" class="net.spring.ioc.methodConstruct.Person">
<!---->
<property name="name" value="#{'spicygoods'}" />
<property name="age" value="#{price.price()}" />
<property name="Person" value="#{Person}" />
</bean>
輸入:
Person
{name='spicygoods', age=0, person=setterPerson{name='spicy', age=1}}</code></pre>