struts关于页面跳转

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",进行跳转,则传递的参数将丢失。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值