struts2 result type

struts中的result类型总共有9种

<result-types>
            <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
            <result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>
            <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
            <result-type name="httpheader" class="org.apache.struts2.dispatcher.HttpHeaderResult"/>
            <result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/>
            <result-type name="redirectAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
            <result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/>
            <result-type name="velocity" class="org.apache.struts2.dispatcher.VelocityResult"/>
            <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
            <result-type name="plainText" class="org.apache.struts2.dispatcher.PlainTextResult" />
            <result-type name="postback" class="org.apache.struts2.dispatcher.PostbackResult" />
 </result-types>

常用的有

  1.dispatcher:是result的默认类型,同servlet的转发,用于呈现jsp页面

  2.redirect:将用户请求重定向至已经配置好的url

  3.redirectAction:重定向至已经定义好的Action

  4.chain:将一个Action和另一个Action连接起来

  5.stream:将原始数据作为流返回浏览器端,适用于文件的下载

————我愿乘风破浪,踏遍黄沙海洋
原文地址:https://www.cnblogs.com/wb1993/p/5615857.html