首页 > 代码库 > EL标签使用
EL标签使用
<%@ page language= "java" contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta charset="utf-8">
<title>EL使用</title>
</head>
<body>
<%
pageContext.setAttribute("info", "page属性范围");
request.setAttribute("info", "request属性范围");
session.setAttribute("info", "session属性范围");
application.setAttribute("info", "application属性范围");
pageContext.setAttribute("flagA", true);
pageContext.setAttribute("flagB", false);
pageContext.setAttribute("num1", 20);
pageContext.setAttribute("num2", 30);
pageContext.setAttribute("num3", 40);
%>
<%--<h3>${info} </h3> --%>
<%--指定属性范围 --%>
<h3>${pageScope.info} </h3>
<h3>${requestScope.info} </h3>
<h3>${sessionScope.info} </h3>
<h3>${applicationScope.info} </h3>
<%--验证逻辑运算符 --%>
<h3>与操作${flagA && flagB}和${flagA and flagB} </h3>
<h3>或操作${flagA || flagB}和${flagA or flagB} </h3>
<h3>非操作${!flagA}和${not flagB} </h3>
<%--验证逻辑运算符 --%>
<h3>加法操作${num1+num2} </h3>
<h3>减法操作${num1-num2} </h3>
<h3>乘法操作${num1*num2} </h3>
<h3>除法操作${num1/num2}和 ${num1 div num2}</h3>
<h3>取摸操作${num1%num2} 和 ${num1 mod num2}</h3>
<h3>empty操作${empty info} </h3>
<h3>三目运算操作${num1>num2?"小于":"大于"} </h3>
<h3>括号操作${num1*(num2+num3)} </h3>
<h3>相等判断${num2 == num1}和${num2 eq num3} </h3>
<h3>不等判断${num2 != num3} 和${num2 ne num3}</h3>
<h3>小于判断${num2 < num3} 和${num2 lt num3}</h3>
<h3>大于判断${num2 >num3} 和${num2 gt num3}</h3>
<h3>大于等于判断${num2 <= num3} 和${num2 le num3}</h3>
<h3>小于等于判断${num2 >= num3}和${num2 ge num3} </h3>
</body>
</html>
EL标签使用