EL运算符
来源:互联网 发布:网络监控技术员 编辑:程序博客网 时间:2024/06/06 12:45
算术运算符: 运算符号:+、-、*、/或div、%或mod
1.
request.setAttribute("a",1); //request.setAttribute("a",new Integer(1));request.setAttribute("b",2); //request.setAttribute("a",new Integer(2)); 两种方式都可以request.getRequestDispatcher("result.jsp").forward(request, response);
加法:${a+b}<br/>减法:${a-b}<br/>乘法:${a*b}<br/>除法:${a/b}<br/> ${a div b}<br/>取余:${a%b}<br/> ${a mod b}<br/>
三目运算:${a==1?"相等":"不相等"}<% request.setAttribute("a",1);%>${a==1?"相等":"不相等"}<h4>单选</h4><input type="radio" name="sex" value="0" ${a==0?"checked":""}/>女<input type="radio" name="sex" value="1" ${a==1?"checked":""}/>男<br/><br/><h4>复选</h4><c:set var="hobbies" value="${fn:join(hobbies,' ') }"></c:set><input type="checkbox" name="fruit" value="apple" ${fn:contains(hobbies,"apple")?"checked":""}/>苹果<input type="checkbox" name="fruit" value="banana" ${fn:contains(hobbies,"banana")?"checked":""}/>香蕉<input type="checkbox" name="ball" value="football" ${fn:contains(hobbies,"football")?"checked":""}/>足球<input type="checkbox" name="ball" value="basketball" ${fn:contains(hobbies,"basketball")?"checked":""}/>篮球<br/><br/><h4>下拉列表</h4><select><option value="" ${a==””?"selected":""}>--请选择--</option><option value="1" ${a==1?"selected":""}>衣服</option><option value="2" ${a==2?"selected":""}>鞋子</option></select>
2.<% request.setAttribute("a",1);%> //<% request.setAttribute("a", new Integer(1));%><% request.setAttribute("b",2);%> //<% request.setAttribute("a", new Integer(2));%>加法:${a+b}<br/>减法:${a-b}<br/>乘法:${a*b}<br/>除法:${a/b}<br/> ${a div b}<br/>取余:${a%b}<br/> ${a mod b}<br/>
关系运算符:
运算符符号:==或eq、
!=或ne、
<或lt(即less than)、
>或gt(即great than)、
<=或 le(即less equal)、
>=或 ge(即great equal)
<% request.setAttribute("num1",1);%><% request.setAttribute("num2",2);%><% request.setAttribute("str1","student");%><% request.setAttribute("str2","students");%><% request.setAttribute("student1",new Student(22,"临汾","阿丹"));%><% request.setAttribute("student2",new Student(22,"山东","阿洁"));%>数值:${num1==num2 } ${num1 eq num2 }<br/><br/>字符串:${str1==str2 } ${str1 eq str2 }<br/><br/>自定义类:${student1==student2 } ${student1 eq student2 }<br/><br/>不等于:${num1!=num2 } ${num1 ne num2 }<br/><br/>小于:${num1<num2 } ${num1 lt num2 }<br/><br/>小于等于:${num1<=num2 } ${num1 le num2 }<br/><br/>大于:${num1>num2 } ${num1 gt num2 }<br/><br/>大于等于:${num1>=num2 } ${num1 ge num2 }<br/><br/>
逻辑运算符:
运算符符号:&& 或 and、|| 或 or、! 或 not(注意:只能对boolean型数据运算)
empty运算符
说明:如果集合或数组中没有数据,或者其值为null,则empty判断为true;not empty判断为false。
<% request.setAttribute("a",true);%><% request.setAttribute("b",false);%>逻辑与:${a&&b } ${a and b }<br/><br/>逻辑或:${a||b } ${a or b }<br/><br/>逻辑非:${!b } ${not b }<br/><br/>empty:${empty c } ${!empty c } ${not empty c }
0 0
- EL运算符
- EL运算符
- EL运算符
- el运算符
- EL关系运算符
- EL运算符
- El表达式运算符
- EL关系运算符
- EL 中的运算符
- El表达式运算符
- EL运算符
- El表达式运算符
- EL的关系运算符
- EL表达式---关系运算符
- EL表达式三元运算符
- EL表达式中的运算符
- 第六章EL和JSTL> 3-el表达式运算符
- el运算符(逻辑运算符)
- 什么是REST架构
- java抽象类继承理解
- 微锁密码管理器
- 2017第五届中国网络安全大会4月30日前报名享受早鸟票8折优惠
- spring4 注解方式集成mongoDB
- EL运算符
- 数据库索引
- Git使用的一些bug及解决方法
- RBAC新解:基于资源的权限管理(Resource-Based Access Control)
- 删除文件及文件夹下文件
- 编写shellcode(vs2017)
- 浅谈Java SE、Java EE、Java ME三者的区别
- 深度学习 15. 全连接和区域连接,fully connected 和 local connected, 解释说明(最简单的解释)
- 【23种设计模式】之 目录