五侯山,农行猴年纪念币预约,混蛋神风流史txt
原文链接:http://www.yiidian.com/spring/spring-el-three-mesh-operator.html
spel支持三目运算符,以此来实现条件语句。
item类:
package com.yiidian.domain; /** * * @author http://www.yiidian.com * */ public class item { private int qtyonhand; public int getqtyonhand() { return qtyonhand; } public void setqtyonhand(int qtyonhand) { this.qtyonhand = qtyonhand; } }
customer类:
package com.yiidian.domain; import java.io.serializable; /** * * @author http://www.yiidian.com * */ public class customer implements serializable{ private boolean warning; public boolean iswarning() { return warning; } public void setwarning(boolean warning) { this.warning = warning; } @override public string tostring() { return "customer [warning=" + warning + "]"; } }
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p" 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.xsd"> <bean id="customer" class="com.yiidian.domain.customer"> <property name="warning" value="#{itembean.qtyonhand < 100 ? true : false}" /> </bean> <bean id="itembean" class="com.yiidian.domain.item"> <property name="qtyonhand" value="99" /> </bean> </beans>
package com.yiidian.test; import org.junit.test; import org.springframework.context.applicationcontext; import org.springframework.context.support.classpathxmlapplicationcontext; import com.yiidian.domain.customer; /** * @author http://www.yiidian.com * */ public class demo1 { @test public void test1() { applicationcontext context = new classpathxmlapplicationcontext("applicationcontext.xml"); customer customer = (customer)context.getbean("customer"); system.out.println(customer); } }
源码下载:http://pan.baidu.com/s/1qymlkfe
欢迎关注我的公众号::一点教程。获得独家整理的学习资源和日常干货推送。
如果您对我的系列教程感兴趣,也可以关注我的网站:
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
浅析我对 String、StringBuilder、StringBuffer 的理解
使用IDEA搭建SSM框架的详细教程(spring + springMVC +MyBatis)
Springboot整合freemarker 404问题解决方案
引入mybatis-plus报 Invalid bound statement错误问题的解决方法
网友评论