javaBean,el表达式
javaBean说到底是一个类,
1、使用public修饰
2、公共的无参构造方法
3、包含属性的操作方法
el表达式,原理是pageContext里有个方法findAttribute()
<%@ 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>
<%
//pageContext.setAttribute("msg","pageContextValue");
request.setAttribute("msg","requestValue");
session.setAttribute("msg","sessionValue");
application.setAttribute("msg","applicationValue");
%>
${msg}
</body>
</html>
el的内置对象或者叫隐式对象
使用eltest?username=xiao来访问就可以看到值
<%@ 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>
username=${param.username}
</body>
</html>
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>
<%
pageContext.setAttribute("msg","pageContextValue");
request.setAttribute("msg","requestValue");
session.setAttribute("msg","sessionValue");
application.setAttribute("msg","applicationValue");
%>
pageContext=${pageScope.msg}<br/>
request=${requestScope.msg}<br/>
session=${sessionScope.msg}<br/>
application=${applicationScope.msg}<br/>
</body>
</html>