05 dispatcher redirect chain redirectAction的使用

1.   修改struts.xml

      <action name="user_dispatcher">

           <result type="dispatcher">/Adminadd_success.jsp</result>

        </action>

       

        <action name="user_redirect">

            <result type="redirect">/Adminadd_success.jsp</result>

        </action>

       

        <action name="user_chain">

            <result type="chain">user_redirect</result>

        </action>

       

        <action name="user_redirectAction">

            <result type="redirectAction">user_dispatcher</result>

</action>

2.   运行

启动tomcat

1)        访问http://localhost:2000/Gao_struts2/struts/user_dispatcher.action

     页面显示:user addsuccess!

     页面地址依然是:http://localhost:2000/Gao_struts2/struts/user_dispatcher.action

2)       访问:http://localhost:2000/Gao_struts2/struts/user_redirect.action
 页面显示:user add success!
  
页面地址改为:http://localhost:2000/Gao_struts2/Adminadd_success.jsp

3)        访问:http://localhost:2000/Gao_struts2/struts/user_chain.action

 页面显示:user add success!

 页面地址改为:http://localhost:2000/Gao_struts2/Adminadd_success.jsp

4)        访问:http://localhost:2000/Gao_struts2/struts/user_redirectAction.action

 页面显示:user add success!

     页面地址改为:http://localhost:2000/Gao_struts2/struts/user_dispatcher.action

3.   总结

1)        dispatcherredirect用于action跳转到页面。

2)        chainredirectAction用于action跳转到action

3)        dispatcherchain是服务器端跳转,所以他们不会改变客户端浏览器中访问的地址。

4)        redirectredirectAction是客户端跳转,就是说客户端发起action的请求后,服务端会返回action返回的对应的地址给客户  端,客户端会再次发起新的请求给服务器,其中客户端浏览器的地址就是客户端最后访问服务端的地址。 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值