一次Request請(qǐng)求只有一個(gè)值棧(Value Stack)。
Action才有Value Stack,JSP頁面沒有,如果在JSP頁面里想取參數(shù)值,可以從Stack Context中獲取。
因此,在result的type="redirect"時(shí),如果有傳參數(shù),可以從Stack Context中獲取。
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<constant name="struts.devMode" value="true" />

<package name="user" namespace="/user" extends="struts-default">
<action name="user" class="com.bebig.struts2.user.action.UserAction">
<!-- 用$符號(hào)來取Value Stack里的值 -->
<result type="redirect">/success.jsp?t=${type}</result>
</action>

</package>

</struts>
測(cè)試頁面代碼片斷:
<ul>
success.
</ul>
<br>
<s:property value="t" />從Value Stack里取不到t的值,因?yàn)镴SP頁面是沒有Value Stack的。
<br>
<s:property value="#parameters.t" />這里從Stack Context里取得t的值。
<s:debug></s:debug>
Action才有Value Stack,JSP頁面沒有,如果在JSP頁面里想取參數(shù)值,可以從Stack Context中獲取。
因此,在result的type="redirect"時(shí),如果有傳參數(shù),可以從Stack Context中獲取。
struts.xml
























