spring--(11)表达式语言(spel)

//Address类java

public class Address {
	private String city;
	private String street;
}

//Car类code

public class Car {
	private String brand;
	private double price;
	private double typeCircle;
}

//person类xml

public class Person {
	private String name;
	private Car car;
	private String city;
	private String info;
}

//xml配置文件ci

<bean id="address" class="com.test.autowired.Address">
		<!-- 使用spel为属性赋一个字面值 -->
		<property name="city" value="#{'BeiJing'}"></property>
		<property name="street" value="Wudaokou"></property>
	</bean>
	
	<bean id="car" class="com.test.autowired.Car">
		<property name="brand" value="Audi"></property>
		<property name="price" value="500000"></property>
		<property name="typeCircle" value="#{T(java.lang.Math).PI * 80}"></property>
	</bean>
	
	<bean id="person" class="com.test.autowired.Person">
		<property name="car" value="#{car}"></property>
		<property name="city" value="#{address.city}"></property>
		<property name="info" value="#{car.price > 300000 ? '金领':'白领'}"></property>
	</bean>
相关文章
相关标签/搜索