场景:在请求的URL中传参,之后参数显示在jsp中
如果result的type是forward类型(type=dispatcher/chain),则共享值栈(因为相当于只有一次request请求),不需要在xml中取参数值
xml中
<action name="r1" >
<result>/resultParam.jsp</result>
</action>
<action name="r2" class="com.resultParam.ResultParamAction">
<result type="chain">r1</result>
</action>
jsp中
from value stack<s:property value="type"></s:property>
如果result的type是redirect类型(type=”redirect”,redirectAction),则不共享值栈,需要在xml中取值后,在JSP中用OGNL表达式取值(ValueStack,StackContext)
xml中
<action name="r3" class="com.resultParam.ResultParamAction">
<result type="redirect">/resultParam.jsp?type=${type}</result>
</action>
<action name="r4" class="com.resultParam.ResultParamAction">
<result type="redirectAction">r1?type=${type}</result>
</action>
jsp中
from stack context<s:property value="#parameters.type"></s:property>
访问图: