Struts2 中result type属性说明

首先看一下在struts-default.xml中对于result-type的定义:

<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-types>

chain:用来处理Action链,被跳转的action中仍能获取上个页面的值,如request信息.

dispatcher:用来转向页面,通常处理JSP.

freemaker:处理FreeMarker模板.

httpheader:控制特殊HTTP行为的结果类型.

redirect:重定向到一个URL,被跳转的页面中丢失传递的信息,如request.

redirectAction:重定向到一个Action,跳转的页面中丢失传递的信息.

stream:向浏览器发送InputSream对象,通常用来处理文件下载,还可用于返回AJAX数据.

velocity:处理Velocity模板.

xslt:处理XML/XLST模板.

plainText:显示原始文件内容,例如文件源代码.


重点说一下redirect和redirectAction的区别:

(1)使用redirect需要后缀名,使用redirect-action可以不需要后缀名.

(2)type="redirect"的值可以转到其它命名空间下的action,而redirect-action只能转到同一命名空下的action,因此它可以省略.do的后缀直接写action的名称.

Struts2 中result type属性说明的更多相关文章

  1. Struts2.xml中result type属性说明

    在struts2配置XML里,result中type属性有以下几种: 1.dispatcher:服务器跳转到前台,后面跟着可以是JSP.htm等等前台页面,默认是这种. 2.redirect:客户端跳 ...

  2. struts2.xml 中result type属性说明

    chain           用来处理Action链,被跳转的action中仍能获取上个页面的值,如request信息.           com.opensymphony.xwork2.Acti ...

  3. struts2 中 result type="stream"

    Stream result type是Struts2中比较有用的一个feature.特别是在动态生成图片和文档下载的情况下 1:图片验证码: Action类,action主要要提供一个获取InputS ...

  4. Struts2 中 result type=”json” 的参数解释

    转自:http://wangquanhpu.iteye.com/blog/1461750 1, ignoreHierarchy 参数:表示是否忽略等级,也就是继承关系,比如:TestAction 继承 ...

  5. struts2 action result type类型

    struts2 action result type类型 1.chain:用来处理Action链,被跳转的action中仍能获取上个页面的值,如request信息. com.opensymphony. ...

  6. Struts2中 Result类型配置详解

    一个result代表了一个可能的输出.当Action类的方法执行完成时,它返回一个字符串类型的结果码,框架根据这个结果码选择对应的result,向用户输出.在com.opensymphony.xwor ...

  7. 【Struts】strust.xml中<result type="">所有类型详解

    在默认时,<result>标签的type属性值是“dispatcher”(实际上就是转发,forward).开发人员可以根据自己的需要指定不同的类型,如redirect.stream等.如 ...

  8. 04. struts2中Result配置的各种视图转发类型

    概述 <action name="helloworld" class="com.liuyong666.action.HelloWorldAction"&g ...

  9. 为什么要在<button>元素中添加type属性

    在HTML中<button> 标签定义一个按钮. <button type="button">Click Me!</button> 在 butt ...

随机推荐

  1. 《ASP.NET1200例》C# WINFORM程序的三层架构如何建立的。

    先添加-新建项目-windows应用程序,然后在右边的解决方案资源管理器上面,在当前的解决方案上面右击,点,添加-新建项目-类库,分别建立.DAL,BLL,Model三个项目,然后,在DAL项目上右击 ...

  2. JS 保留小数点后面2位小数

    1. 最笨的办法....... [我就怎么干的.........] function get(){    var s = 22.127456 + "";    var str = ...

  3. 72 [面试题]如果不使用if-else和比较运算符,你知道如何求解2个数字中的较大一个吗?

    [本文链接] http://www.cnblogs.com/hellogiser/p/max-of-numbers-without-comparations.html [题目] 不使用if-else和 ...

  4. ARM 处理器的几个相关术语

    生产ARM的厂商很多,自然ARM处理器的名字就五花八门.但是,它们有些共同点,那就是:架构和核心. 架构这个概念太宽不太懂,一般不同的架构会有不同的指令集,在不同的架构下面还可以有多种核心.核心就是指 ...

  5. Java for LeetCode 077 Combinations

    Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...

  6. OpenGL在 win8 64bits系统下的配置

    1 program files(x86)与program files 在64位系统下,为了更好的兼容32位程序,在安装一些32位程序(注意某些程序他就是32位的),会默认扔到program files ...

  7. iphone越狱还原

    在Cydia 里安装Impactor 就行了 .在操作时需要全程联网: .请至少保证 % 的电量以防止在恢复过程出现断电的情况(建议将设备连接至电源): .设备将恢复至出厂状态,所有用户数据都将被清除 ...

  8. Circle(codevs 3134)

    题目描述 Description 在一个圆上,有2*K个不同的结点,我们以这些点为端点,连K条线段,使得每个结点都恰好用一次.在满足这些线段将圆分成最少部分的前提下,请计算有多少种连线的方法 输入描述 ...

  9. xampp 访问出现New XAMPP security concept

    在浏览器输入 http://60.10.140.22/xampp出现以下错误信息: Access forbidden! New XAMPP security concept: Access to th ...

  10. 如何从本地把项目上传到github

    在本地项目所在目录按以下步骤操作 echo # test >> README.md git init git add README.md git add . git commit -m . ...