前台显示

整体代码

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" %>
    <%@ page import="bean.*,java.util.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<br>----EL4种类型接受数据----</br>
<%
	pageContext.setAttribute("name", "page");
	request.setAttribute("name", "request");
	session.setAttribute("name", "session");
	application.setAttribute("name", "application");
%>

${name }<br>
${pageScope.name }<br>
${requestScope.name }<br>
${sessionScope.name }<br>
${applicationScope.name }<br>

<br>----EL接收EL接收数据自定义类----</br>
<%
	Strudent s=new Strudent("小明",30);
	request.setAttribute("s", s);
%>
${s.name }<br>
${s.age }<br>
${requestScope.s.name }<br>
${requestScope.s.age }<br>

<br>----EL接收数据自定义类----</br>
<%
	School sc=new School("北京大学",s);
	request.setAttribute("School", sc);
%>
The value come from School:  ${School.stu.name }<br>
<br>----EL接收数据list----</br>
<%
	List<Strudent> list=new ArrayList<>();
	list.add(new Strudent("小三", 30));
	list.add(new Strudent("小四", 31));
	list.add(new Strudent("小五", 32));
	list.add(new Strudent("小六", 33));
	request.setAttribute("list", list);
%>
${list[0].name }<br>

<br>----EL接收数据map----</br>
<%
	Map<String,String> map=new HashMap<>();
	map.put("username", "Davis");
	map.put("password","password");
	request.setAttribute("map", map);
%>
用户名:${map.username }<br>
密码:${map.password }<br>

<br>----El pageContext 接收数据----</br>
${pageContext.request.contextPath }<br>
${param.name }<br>
${paramValues.hobby[0] }<br>
${paramValues.hobby[1] }<br>

</body>
</html》

EL4种类型接受数据

<%
	pageContext.setAttribute("name", "page");
	request.setAttribute("name", "request");
	session.setAttribute("name", "session");
	application.setAttribute("name", "application");
%>

${name }<br>
${pageScope.name }<br>
${requestScope.name }<br>
${sessionScope.name }<br>
${applicationScope.name }<br>

EL接收EL接收数据自定义类

<%
	Strudent s=new Strudent("小明",30);
	request.setAttribute("s", s);
%>
${s.name }<br>
${s.age }<br>
${requestScope.s.name }<br>
${requestScope.s.age }<br》

EL接收数据自定义类

<%
	School sc=new School("北京大学",s);
	request.setAttribute("School", sc);
%>
The value come from School:  ${School.stu.name }<br>

EL接收数据list

<%
	List<Strudent> list=new ArrayList<>();
	list.add(new Strudent("小三", 30));
	list.add(new Strudent("小四", 31));
	list.add(new Strudent("小五", 32));
	list.add(new Strudent("小六", 33));
	request.setAttribute("list", list);
%>
${list[0].name }<br>

EL接收数据map

<%
	Map<String,String> map=new HashMap<>();
	map.put("username", "Davis");
	map.put("password","password");
	request.setAttribute("map", map);
%>
用户名:${map.username }<br>
密码:${map.password }<br>

<br>----El pageContext 接收数据----</br>
${pageContext.request.contextPath }<br>
${param.name }<br>
${paramValues.hobby[0] }<br>
${paramValues.hobby[1] }<br>