struts2的跳转配置极其作用和含义

 

forward和redirect的四大区别:

Forward:跳转后地址栏不发生变化;可以得到request中的数据;forward只能到内网路径;

                Forward后面的语句会打印其后面的语句,所以要写return{过程:执行完forward语句跳转到指定路径,当指定路径的业务运行完之后会再返回,接着执型forward  下面的语句}

Redirect:跳转后地址栏发生变化,得不到request中的数据,redirect可以跳到外网路径。Redirect后面的语句会被执行,把servlet中的代码全部执行完才会重定向。

Chain是服务器内部跳转,相当于forward

Action forwardjsp叫做dispatcher

Action forwardaction叫做chain

Action redirect到jsp叫做redirect

Action redirectaction叫做redirectaction

<struts>

<constant name="struts.action.extension" value="action,abc,,"></constant>

<constant name="struts.devMode" value="true"></constant>

<constant name="struts.locale" value="zh_CN"></constant>

<constant name="struts.enable.DynamicMethodInvocation" value="false"></constant>

<package name="default" namespace="/" extends="struts-default"> 

<action name="a" >

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

</action>//action 内部跳转到jsp

<action name="b">

<result type="redirect">/index.jsp</result>//action重定向跳转到jsp

</action>

<action name="c">

<result type="chain">a</result>//action内部跳转到action

</action>

<action name="d">

<result type="redirectAction">b</result>//action重定向跳转到action

</action>

</package>

</struts>

挎包跳转:

<action name="e">

<result type="redirectAction">

<param name="namespace">/user</param>

<param name="actionName">list</param>

</result>

</action>

</package>

<package name="user" namespace="/user" extends="struts-default">

<action name="list">

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

</action>

</package>

   

</struts>

全局跳转:

<package name="default" namespace="/" extends="struts-default"> 

<!-- 全局跳转 -->

<global-results name="error">/error.jsp</global-results>

<action name="a" >

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

</action>

<action name="b">

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

</action>

<action name="c">

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

</action>

<action name="d">

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

</action>

<action name="e">

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值