<body>
<% //相当于request.setAttribute("age", 60); %>
<%-- <s:set name="age" value="60"/>
<h1></h1>
登录成功! 欢迎您, ${age}
<hr>
<h1>上下文对象request能取到request的值,,原来上下文对象叫request</h1>
<%=request.getAttribute("age") %>
<hr>
<h1>页面级存储对象pageContext能取到request的值
</h1>
<%=pageContext.getAttribute("age") %>
<hr>
<h1>Session不能取到request的值
</h1>
<%=session.getAttribute("age") %>
<hr>
<h1>服务器对象application不能取到request的值
</h1>
<%=application.getAttribute("age") %> --%>
<hr>
<!-- 这个地方只能保存数字,不能为什么保存字符串会没有 -->
<s:set name="username" value="100" scope="session"/>
scope="session"' 能不能取到值,肯定可以,范围变大了,是不是? 不是,只要存了,都可以找到? : ${username}
<h1>上下文对象request能取到request的值,,原来上下文对象叫request
</h1>
<%=request.getAttribute("username") %><h2>session与request没有任何关系
</h2>
<hr>
<h1>页面级存储对象pageContext能取到request的值
</h1>
<%=pageContext.getAttribute("username") %>
<hr>
<h1>Session不能取到request的值
</h1>
<%=session.getAttribute("username") %>
<hr>
<h1>服务器对象application不能取到request的值
</h1>
<%=application.getAttribute("username") %>
</body>
转载于:https://www.cnblogs.com/xuedexin/articles/5677536.html