Struts2-ResultType-1-结果类型

前两种常用,前四种了解,其他不常用(后面会仔细研究,用到再说)
1. dispatcher
(常用,服务器端跳转,浏览器的访问地址对客户透明)
不配的话,默认是dispatcher(用服务器跳转到结果页面jsp,html,freemarker页面,但不能是action)
2. redirect
客户端跳转,跳转到页面
3. chain
用forward的方式,访问action
4. redirectAction
客户端(redirect)跳转到Action
5. freemarker
6. httpheader
发http的头信息过去
7. stream
下载
8. velocity
与freemarker类似,没freemarker好用
9. xslt
xml相关的修饰
10. plaintext
会把页面源码显示出来
11. tiles
把页面分成几块

 <package name="resultType" namespace="/r" extends="struts-default" >
        <global-allowed-methods>regex:.*</global-allowed-methods>
        <!-- 访问http://localhost:8080/hello/r/r1,url显示 http://localhost:8080/hello/r/r1-->
        <action name="r1"  >
            <result type="dispatcher">/resultType/r1.jsp</result>
        </action>
        <!--访问http://localhost:8080/hello/r/r2,浏览器显示http://localhost:8080/hello/resultType/r2.jsp-->
        <action name="r2"  >
            <result type="redirect">/resultType/r2.jsp</result>
        </action>
        <!--chain访问同一个包下的action:注意action前面不要加斜杠-->
        <!-- 访问http://localhost:8080/hello/r/r3,url显示http://localhost:8080/hello/r/r3,展示r1的jsp-->
        <action name="r3"  >
            <result type="chain">r1</result>
        </action>
        <!--chain访问不同包下的action:注意action前面不要加斜杠-->
        <action name="r5"  >
            <result type="chain">
               <param name="actionName">index</param>
                <param name="namespace">/front</param>
            </result>
        </action>
       <!--访问http://localhost:8080/hello/r/r4,url显示http://localhost:8080/hello/resultType/r2.jsp,展示r2的jsp-->
        <action name="r4"  >
            <result type="redirectAction">r2</result>
        </action>

    </package>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值