目录
1. 定义
Expression Language表达式语言(EL表达式),替代jsp页面中数据访问的复杂编码,可以非常便捷地取出域对象(pageContext、request、session、application)中保存的数据,前提是一定要先setAttribute,EL就相当于在简化getAttribute。
格式:${变量名}变量名就是setAttribute的key值。
2. 案例1(比较使用el表达式的代码区别)
2.1 不使用el表达式
el.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setAttribute("name", "tom");
request.getRequestDispatcher("el2.jsp").forward(request,response);
%>
</body>
</html>
el2.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>