result的类型(8)

1.dispatcher

服务器端跳转,result如果我们不指定它的类型,默认的是dispatcher,dispatcher的意思是运用服务器跳转,forward到一个页面(比如jsp页面,HTML页面),但是,不能是action

2.redirect

客户端跳转,只能跳转到视图,不能到action

3.chain

服务器端跳转,forward到一个action

4.redirectAction

客户端跳转,跳转到一个action

5.freemarker

使用freemarker的时候会用到

6.stream

下载文件的时候遇到

<?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>
	    </action>
	    
    </package>
</struts>

服务器端跳:客户端发起一个请求访问某一个URL地址,在服务器端发生了跳转,客户端根本就不知道,浏览器上的访问地址不会发生改变


 客户端跳转:客户端发起一个请求,发现是redirect,它会反馈给浏览器,浏览器会重新发起新的请求到新的地址,浏览器地址栏中的URL会发生改变

猜你喜欢

转载自weigang-gao.iteye.com/blog/2156410
今日推荐