SeaLoginAction类中使用
return actionMapping.findForward("returnData");来进行页面跳转。
在struts-config.xml文件中进行相应的配置
<action path="/Login" scope="request" type="com.pwl.application.sea.main.action.SeaLoginAction">
<forward contextRelative="true" redirect="true" name="returnData" path="/skin/seaHall/TestGame.jsp" />
</action>
1.contextRelative 设为true时表示当前path属性以/开头时,给出的是相对于当前上下文的url。默认为false
如果当前路径为http://localhost/moduleA/
<forward name="..." path="/target.jsp" redirect="true" contextRelative="false"/>
执行以上forward时会转向http://localhost/moduleA/target.jsp
如contextRelative="true"时,会转向http://localhost/target.jsp
2.redirect设置响应返回类型,redirect="true":重定向 缺省值为 redirect="false":转发。
3.path="/skin/seaHall/TestGame.jsp" 为要跳转到得目标页面。
注意:如果在SeaLoginAction类中使用
request.setAttribute("uid",uid);来传递参数
则设置redirect="true",进行跳转,则传递的参数将丢失。