首先看一下在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 中result type属性说明

    Struts2 中result type属性说明 首先看一下在struts-default.xml中对于result-type的定义: <result-types><result-t ...

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

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

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

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

  4. struts2 result type类型

    result标签中type的类型 类型 说明 chain 用于Action链式处理 dispatcher 用于整合JSP,是<result>元素默认的类型 freemarket 用来整合F ...

  5. Struts2 result type(结果类型)

    转自:http://www.cnblogs.com/liaojie970/p/7151103.html 在struts2框架中,当action处理完之后,就应该向用户返回结果信息,该任务被分为两部分: ...

  6. struts2 Result Type四个常用转跳类型

    Result的四个常用转跳类型分别为 Dispatcher 用来转向页面,是Struts的默认形式 Redirect   重定向到一个URL Chain  用来处理Action链 RedirectAc ...

  7. Struts2 result type

    Struts2支持的不同类型的返回结果为: type name 说明 dispatcher 缺省类型,用来转向页面,通常处理JSP chain 转向另一个action,用来处理Action链 redi ...

  8. struts2 result type的类型

    一共十种类型 1.dispatcher 默认的类型,相当于servlet的foward,服务器端跳转.客户端看到的是struts2中配置的地址,而不是真正页面的地址.一般用于跳转到jsp页面 2.re ...

  9. Struts2 配置文件result的name属性和type属性

    Struts2 配置文件result的name属性和type属性:Name属性SUCCESS:Action正确的执行完成,返回相应的视图,success是 name属性的默认值: NONE:表示Act ...

随机推荐

  1. linux简单文件管理命令的使用

    在linux系统中,命令的使用要方便于图形界面的使用,上一个博客介绍了如何使用PuTTy远程登录linux,当然,我使用的是本地登录(手动滑稽) 经过一星期课余时间的了解,大致了解了一些简单的文件管理 ...

  2. linux系统基础之---文件系统与日志(基于centos7.4 1708)

  3. 路由(二) router-link的使用

    main.js import Vue from 'vue'import App from './App'import VueRouter from 'vue-router'import footer ...

  4. 本人擅长Ai、Fw、Fl、Br、Ae、Pr、Id、Ps等

    本人擅长Ai.Fw.Fl.Br.Ae.Pr.Id.Ps等软件的安装与卸载,精通CSS.JavaScript.PHP.ASP.C.C++.C#.Java.Ruby.Perl.Lisp.python.Ob ...

  5. while 循环,格式化输出和运算编码

    今日内容 1.while循环 while Ture:             content = input ("请输入你要喷的内容",输入Q退出)             if ...

  6. 7、Linux应用程序地址布局

    程序构成 在学习Linux应用程序开发时,经常会遇到如下概念: 代码段.数据段.BSS段(Block Started by Symbol,又名:未始化数据段) .堆(heap)和栈(stack).始化 ...

  7. 《PHP发送邮件PHPMailer》系列分享专栏

    <PHP发送邮件PHPMailer>已整理成PDF文档,点击可直接下载至本地查阅https://www.webfalse.com/read/201726.html 文章 PHPMailer ...

  8. Scala学习笔记(三)—— 方法和函数

    1. 方法 方法使用 def 定义: def 方法名(参数名:参数列表,…) :返回值类型 = { 方法结构体 } scala> def add(x : Int ,y : Int):Int = ...

  9. 洛谷九月月赛T1 思考

    很迷的一道题目,刚开始直接枚举n个1,然后去mod m ,爆0,后来发现一个神奇性质:找到递推公式An=An-1*10+1,枚举n,不断mod m,每递推一次就1的个数加一.居然可行! 听说余数具有可 ...

  10. 【转】odoo 新API装饰器中one、model、multi的区别

    http://blog.csdn.net/qq_18863573/article/details/51114893 1.one装饰器详解 odoo新API中定义方式: date=fields.Date ...