struts2几种常见的结果类型result_type

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <constant name="struts.devMode" value="true" />
    <package name="resultTypes" namespace="/r" extends="struts-default">
	    
	    <action name="r1">
	    	<result type="dispatcher">/r1.jsp</result>
	    </action>
	    
	    <action name="r2">
	    	<result type="redirect">/r2.jsp</result>
	    </action>
	    
	    <action name="r3">
	    	<result type="chain">r1</result>
	    </action>
	    
	    <action name="r4">
	    	<result type="redirectAction">r2</result>
	    	<!--  <result type="redirectAction">r1</result> -->
	    </action>
	    
    </package>
</struts>

 

dispatcher:服务器内部转发,默认的.

 

redirect:客户端重定向.

 

chain:用于转发到另外的action,如果这个action在另处的package:使用下面写法 

 <action name="login" class="...">
        <!-- Chain to another namespace -->
        <result type="chain">
            <param name="actionName">dashboard</param>
            <param name="namespace">/secure</param>
        </result>
    </action>

 路径显示是这个action

 

 

 

redirectAction:重定向到另外的action

 

 

 

 

 

 

 

 官方文档里有11种之多,其它的平时也很少用到,具体用法帮助文档有详细说明

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值