1.页面之间的转发(type为返回类型,struts-default.xml配置的,dispatcher是默认的):
<struts>
<package name="demo" namespace="/test" extends="struts-default">
<action name="login" class="com.codingdict.actions.LoginAction">
<result type="dispatcher">/welcome.jsp</result>
</action>
</package>
</struts>
2.页面之间的重定向:
<struts>
<package name="demo" namespace="/test" extends="struts-default">
<action name="login" class="com.codingdict.actions.LoginAction">
<!-- <result type="redirect">/welcome.jsp?uname=${name}&uage=${age}</result> -->
<result type="redirect">
<param name="location">/welcome.jsp</param>
<param name="uname">${name}</param>
<param name="uage">${age}</param>
</result>
</action>
</package>
</struts>
3.Action之间的重定向:
<struts>
<package name="demo" namespace="/test" extends="struts-default">
<action name="login" class="com.codingdict.actions.LoginAction">
<result type="redirectAction">
<param name="actionName">other</param>
<param name="uname">${name}</param>
<param name="uage">${age}</param>
</result>
</action>
<action name="other" class="com.codingdict.actions.OtherAction">
<result>/welcome.jsp</result>
</action>
</package>
</struts>
4.Action之间的转发
<struts>
<package name="demo" namespace="/test" extends="struts-default">
<action name="login" class="com.codingdict.actions.LoginAction">
<result type="chain">other</result>
</action>
<action name="other" class="com.codingdict.actions.OtherAction">
<result>/welcome.jsp</result>
</action>
</package>
</struts>
更多struts2详细教程请访问struts2教程