获取域中存储的值、获取域中的值_对象值
获取域中存储的值
获取值:
el表达式只能从域对象中获取值
语法:
1,${域名成.建名}:从指定域获取指定的值
域名:
1. pagescope--> pagecontext
2. requestscope-->request
3. sessionscope--> session
4. applicationscope --> application (servletcontext)
*举例︰在request域中存储了name=张三*获取︰${requestscope.name}
2 ,表示依次从最小的域中查找是否改键对应的值,直到找到为止
案例:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
request.setAttribute("name","张三");
session.setAttribute("age","13");
%>
<%-- 在域中储存数据--%>
<h3>
获取值
</h3>
${requestScope.name}
${sessionScope.age}
${sessionScope.haha}
${name}
</body>
</html>
获取域中的值_对象值
案例:
user user = new user;
user.setAge(12);
user.setName("大傻");
request.setAttribute("s","user");
%>
<%-- 在域中储存数据--%>
<h3>
获取值
</h3>
${requestScope.name}
${sessionScope.age}
${sessionScope.haha}
${s}