condition ? true : false
package com.h3.core;
import org.springframework.beans.factory.annotation.value;
import org.springframework.stereotype.component;
@component("customerbean")
public class customer {
@value("#{itembean.qtyonhand < 100 ? true : false}")
private boolean warning;
public boolean iswarning() {
return warning;
}
public void setwarning(boolean warning) {
this.warning = warning;
}
@override
public string tostring() {
return "customer [warning=" + warning + "]";
}
}
package com.h3.core;
import org.springframework.beans.factory.annotation.value;
import org.springframework.stereotype.component;
@component("itembean")
public class item {
@value("99")
private int qtyonhand;
public int getqtyonhand() {
return qtyonhand;
}
public void setqtyonhand(int qtyonhand) {
this.qtyonhand = qtyonhand;
}
}
输出
customer [warning=true]
<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.h3.core.customer">
<property name="warning"
value="#{itembean.qtyonhand < 100 ? true : false}" />
</bean>
<bean id="itembean" class="com.h3.core.item">
<property name="qtyonhand" value="99" />
</bean>
</beans>
输出结果
customer [warning=true]