尚硅谷公开课--struts2--6--result

本文详细介绍了Struts2框架中结果类型的概念及其使用方法,包括dispatcher、redirect、redirectAction和chain等常用类型,并提供了具体的配置示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

result ,即是struts.xml文件中action的一个子节点,每个action可以有多个result子节点,代表了一种action中execute方法的一种可能的返回值

共两个属性: name,type

type表示结果的响应类型,在struts-default 包的 result-types 节点的 name 属性中定义,常用的有:

dispatcher(默认的): 转发. 同 Servlet 中的转发.

 redirect: 重定向

redirectAction: 重定向到一个 Action
        注意: 通过 redirect 的响应类型也可以便捷的实现 redirectAction 的功能!
        
    <result name="index" type="redirectAction">
        <param name="actionName">testAction</param>
        <param name="namespace">/atguigu</param>
    </result>
    
    或者
    
    <result name="index" type="redirect">/atguigu/testAction.do</result>
        


chain: 转发到一个 Action
        注意: 不能通过 type=dispatcher 的方式转发到一个 Action
        
         只能是:
         
    <result name="test" type="chain">
        <param name="actionName">testAction</param>
        <param name="namespace">/atguigu</param>
    </result>
    
    不能是:
    
    <result name="test">/atguigu/testAction.do</result>

转载于:https://my.oschina.net/iamhere/blog/495611

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值