SpringEL表示式
阿新 • • 發佈:2018-11-04
<?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:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <bean id="car" class="com.Greatest.Spring2.dbutil.Car" > <property name="brand" value="#{'路虎攬勝'}" ></property> <property name="price" value="#{car.brand ne '路虎攬勝'? 100000:200000}" ></property> <!-- <property name="price" value="#{456*2.0}" ></property> LE小於等於 lt小於 gt大於 eq等於 ne不等於 --> <!-- 呼叫靜態方法或靜態屬性:通過 T() 呼叫一個類的靜態方法,它將返回一個 Class Object,然後再呼叫相應的方法或屬性: --> <property name="maxSpeed" value="#{T(java.lang.Math).PI^5}" ></property> <!-- <property name="fat" value="#{true}"></property> --> <!--返回值是布林型別的 <property name="fat" value="#{car.price eq 10000}"></property> --> <property name="fat" value="#{car.price==100000 or car.maxSpeed>10}"></property> </bean> <bean id="person" class="com.Greatest.Spring2.dbutil.Person"> <property name="name" value='#{car.toString()+" "+car.price+""}'></property> <property name="car" value="#{car}"></property> </bean> </beans>