struts2.1关于set标签范围测试的,怎么结果都一样啊????[code=jscript]<%@ page language="java" pageEncoding="GB18030"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<html>
<head>
<title>tags.jsp</title>
</head>
<body>
<h1>tags</h1>
property 取得Action属性的值,值栈中存在:<s:property value="name"/>
property 只是一个字符串:<s:property value="'zifuchuan'"/>
<hr/>
<!--以下是出问题的代码: -->
set:默认
<s:set var="admin" value="name"/>
<strong>page(admin): </strong><s:property value="admin"/>
<strong>request(#request.admin): </strong><s:property value="#request.admin"/>
<strong>session(#session.admin): </strong><s:property value="#session.admin"/>
<strong>application(#application.admin): </strong><s:property value="#application.admin"/>
<strong>ActionContext(#admin): </strong><s:property value="#admin"/>
<hr/>
set:(page)
<s:set var="admin" value="name" scope="page"/>
<strong>page(admin): </strong><s:property value="admin"/>
<strong>request(#request.admin): </strong><s:property value="#request.admin"/>
<strong>session(#session.admin): </strong><s:property value="#session.admin"/>
<strong>application(#application.admin): </strong><s:property value="#application.admin"/>
<strong>ActionContext(#admin): </strong><s:property value="#admin"/>
<hr/>
set:(request)
<s:set var="admin" value="name" scope="request"/>
<strong>page(admin): </strong><s:property value="admin"/>
<strong>request(#request.admin): </strong><s:property value="#request.admin"/>
<strong>session(#session.admin): </strong><s:property value="#session.admin"/>
<strong>application(#application.admin): </strong><s:property value="#application.admin"/>
<strong>ActionContext(#admin): </strong><s:property value="#admin"/>
<hr/>
set:(session)
<s:set var="admin" value="name" scope="session"/>
<strong>page(admin): </strong><s:property value="admin"/>
<strong>request(#request.admin): </strong><s:property value="#request.admin"/>
<strong>session(#session.admin): </strong><s:property value="#session.admin"/>
<strong>application(#application.admin): </strong><s:property value="#application.admin"/>
<strong>ActionContext(#admin): </strong><s:property value="#admin"/>
<hr/>
set:(application)
<s:set var="admin" value="name" scope="application"/>
<strong>page(admin): </strong><s:property value="admin"/>
<strong>request(#request.admin): </strong><s:property value="#request.admin"/>
<strong>session(#session.admin): </strong><s:property value="#session.admin"/>
<strong>application(#application.admin): </strong><s:property value="#application.admin"/>
<strong>ActionContext(#admin): </strong><s:property value="#admin"/>
<hr/>
<s:debug></s:debug>
</body>
</html>[/code]以下是单独每个范围的测试结果:[code=jscript]每个范围分别测试的结果
set:默认
page(admin): MaYachong
request(#request.admin): MaYachong
session(#session.admin): MaYachong
application(#application.admin): MaYachong
ActionContext(#admin): MaYachong
set:(page)
page(admin): MaYachong
request(#request.admin): MaYachong
session(#session.admin):
application(#application.admin): MaYachong
ActionContext(#admin): MaYachong
set:(request)
page(admin): MaYachong
request(#request.admin): MaYachong
session(#admin): MaYachong
application(#application.admin): MaYachong
ActionContext(#admin): MaYachoeng
set:(session)
page(admin): MaYachong
request(#request.admin): MaYachong
session(#session.admin): MaYachong
application(#application.admin): MaYachong
ActionContext(#admin): MaYachong
set:(application)
page(#admin): MaYachong
request(#request.admin): MaYachong
session(#session.admin): MaYachong
application(#application.admin): MaYachong
ActionContext(#admin): MaYachong[/code] |
|