EL

 

  

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setAttribute("test", "测试request");
session.setAttribute("test", "测试EL");
application.setAttribute("test", "测试application");
//网页的上下文
pageContext.setAttribute("test", "测试页面");
%>
page = ${test} <br>
request =${requestScope.test} <br>
session =${sessionScope["test"]} <br>
application =${applicationScope.test} 
<!-- page>request>session>application如果定义的名字一样按照这种顺序查找进行输出 -->
<br>
${"456"+"123"} 
<br>
${123*3}
<br>
${1 eq 1} <!-- 1==1 -->
<br>
${1 ne 1}  <!-- 1 !=1 -->
<br>
${123==123 ? "相等" : "不相等" }
<br>
<a href="test01.jsp?name=tom&password=1234">发送get请求</a>
</body>
</html>

  

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String name =request.getParameter("name");
out.write("name="+name);

%>

<br>
password = ${param.password }  <!--  -->
<br>
name = ${param.name }
<br>
session test =${test}
<br>
application test =${applicationScope.test}
<br>
session test1 =${empty (test1) ? "没找到": test1}
<br>
session test =${empty (test) ? "没找到": test}
</body>
</html>

  

empty  判断变量或对象是否为空,若为空返回true,不为空返回false,

 

posted @ 2016-10-31 18:30  琢磨先生  阅读(221)  评论(0编辑  收藏  举报
AmazingCounters.com