chain   
  
    用来处理Action链,被跳转的action中仍能获取上个页面的值,如request信息。    
   
    com.opensymphony.xwork2.ActionChainResult   
  
dispatcher   
  
    用来转向页面,通常处理JSP   
  
    org.apache.struts2.dispatcher.ServletDispatcherResult   
  
freemaker
   
  
    处理FreeMarker模板   
  
    org.apache.struts2.views.freemarker.FreemarkerResult   
  
httpheader   
  
    控制特殊HTTP行为的结果类型   
  
    org.apache.struts2.dispatcher.HttpHeaderResult

stream   
  
    向浏览器发送InputSream对象,通常用来处理文件下载,还可用于返回AJAX数据   
  
    org.apache.struts2.dispatcher.StreamResult   
  
velocity   
  
    处理Velocity模板   
  
    org.apache.struts2.dispatcher.VelocityResult   
  
xslt   
  
    处理XML/XLST模板   
  
    org.apache.struts2.views.xslt.XSLTResult   
  
plainText   
  
    显示原始文件内容,例如文件源代码   
  
    org.apache.struts2.dispatcher.PlainTextResult   
  
 
plaintext   
  
    显示原始文件内容,例如文件源代码   
  
    org.apache.struts2.dispatcher.PlainTextResult

redirect   
  
    重定向到一个URL ,被跳转的页面中丢失传递的信息,如request  
  
    org.apache.struts2.dispatcher.ServletRedirectResult   
  
redirectAction
   
  
    重定向到一个Action ,跳转的页面中丢失传递的信息,如request      
   
    org.apache.struts2.dispatcher.ServletActionRedirectResult   
  
redirect-action   
  
    重定向到一个Action ,跳转的页面中丢失传递的信息,如request      
   
    org.apache.struts2.dispatcher.ServletActionRedirectResult

注:redirect与redirect-action区别

一、使用redirect需要后缀名 使用redirect-action不需要后缀名
二、type="redirect" 的值可以转到其它命名空间下的action,而redirect-action只能转到同一命名空下的 action,因此它可以省略.action的后缀直接写action的名称。

如:

<result name="success" type="redirect">viewTask.action</result>
<result name="success" type="redirect-action">viewTask</result>

附:redirect-action 传递参数

  1. <action name="enterpreinfo" class="preinfoBusinessAction"    method="enterPreinfoSub">
  2. <result name="success" type="redirect-action">
  3. showpreinfo?preinfo.order_number=${preinfo.order_number}&amp;preinfo.company_name=${preinfo.company_name}
  4. </result>
  5. <result name="error" type="redirect">
  6. <param name="location">/error.jsp</param>
  7. </result>
  8. </action>

因为使用了redirect-action,所以要注意不能将 showpreinf?preinfo.order_number=${preinfo.order_number}写成 showpreinf.action?preinfo.order_number=${preinfo.order_number}

其中${}为EL表达式,获取action:enterpreinfo中属性的值;在这个配置文件里,多个参数的连接符使用了"&amp;",但XML的语法规范,应该使用"&amp;"代替"&",原理和HTML中的转义相同,开始没有注意,在struts分析配置文件时,总是报出这样的错误:

json   一般很容易忽略的一个地方(在EXT中非常有用)
示例
  1. <package name="struts2" extends="json-default" namespace="/">
  2. <action name="login" class="loginAction" method="login">
  3. <result type="json">
  4. <param name="includeProperties">success,result</param>
  5. </result>
  6. </action>
  7. <action name="main" class="loginAction" method="main">
  8. <result name="main">/index.jsp</result>
  9. </action>
  10. </package>
<package name="struts2" extends="json-default" namespace="/">
<action name="login" class="loginAction" method="login">
<result type="json">
<param name="includeProperties">success,result</param>
</result>
</action>
<action name="main" class="loginAction" method="main">
<result name="main">/index.jsp</result>
</action>
</package>
  1. private boolean success  = true;
  2. private String result = "main.action";
  3. //getter和setter方法略
private boolean success  = true;
private String result = "main.action";
//getter和setter方法略
以上的success和result互相对应到了
  1. <param name="includeProperties">success,result</param>
<param name="includeProperties">success,result</param>	
struts2会根据其设置的值匹配跳转
对于json一般情况下很少用到,但是在处理ext的时候会用到这个属性类型,这个地方也是经常被忽略的。

struts2.xml 中result type属性说明的更多相关文章

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

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

  2. Struts2 中result type属性说明

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

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

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

  4. strut2.xml中result param详细设置

    1.Struts2.xml配置文件: 2.Jsp中:说明回调函数一个参数即可.把上面的俩个参数msg和page封装到一起了 3.msg是Action中全局变量 可参考:http://qiaolevip ...

  5. struts2 中 result type="stream"

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

  6. struts2 result type属性说明

    首先看一下在struts-default.xml中对于result-type的定义: <result-types><result-type name="chain" ...

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

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

  8. struts2.Action中的method属性配置

    .Action中的method属性 在struts1.x中我们知道通过继承DispatchAction可以实现把多个Action进行统一操作,在struts2中实现action的统一操作也很简单.我们 ...

  9. XML中的DOCTYPE属性

    一.先来两个小例子 内部dtd将standalone设为真. <?xml version="1.0" standalone="yes"?> < ...

随机推荐

  1. SoapException: Timed out while processing web services request

    情形:动态调用WebService时,语句method.Invoke异常. 异常信息为调用目标发生异常,从异常信息并不能看出问题所在,需要查看InnerException,如标题所述:处理web请求超 ...

  2. Java自学-I/O 中文问题

    Java中的编码中文问题 步骤 1 : 编码概念 计算机存放数据只能存放数字,所有的字符都会被转换为不同的数字. 就像一个棋盘一样,不同的字,处于不同的位置,而不同的位置,有不同的数字编号. 有的棋盘 ...

  3. Python基础9

    Anacanda软件内更新的方法,而不是每次重装整个软件, 整体更新,省时省力. 但仍要掌握单个包更新的方法.

  4. win中Oracle简易客户端和plsql的配置

    连接数据库有2种方式:在本机安装Oracle数据库或者是安装一个oracle简易客户端 当然,简易客户端跟oracle数据库比较少了一些功能 连接方式: 1)简易连接 sqlplus scott/ti ...

  5. 建议各位亲使用LocalDateTime而不使用Date哦

    在项目开发过程中经常遇到时间处理,但是你真的用对了吗,理解阿里巴巴开发手册中禁用static修饰SimpleDateFormat吗 通过阅读本篇文章你将了解到: 为什么需要LocalDate.Loca ...

  6. Bean的一生(Bean的生命周期)

    1. 什么是Bean? Bean是spring中组成应用程序的主体及由spring IoC容器所管理的对象(IoC容器初始化.装配及管理的对象).如果把spring比作一座大型工厂,那么bean就是该 ...

  7. Eclipse properties配置文件中文乱码设置

    1. eclipse中properties的默认编码为  ISO-8859-1, 输入汉字会被转换为unicode 2. 点击  Windows-->preferences  按下图找到更改编码 ...

  8. Flask中before_request与after_request使用

    目录 1.前提,装饰器的弊端 2.before_request与after_request 2.1 before_request分析: 2.2 after_request分析: 3.before_re ...

  9. 06、自动挂载+超级守护进程+时间同步+tcpwrapper+软硬链接+日志管理

    autofs  自动挂载服务   把下面这两条命令做成自动挂载 172.16.2.35:/share/soft /nfs/soft 172.16.2.35:/share/iso  /nfs/iso . ...

  10. 嵌入式linux开发uboot启动内核的机制(二)

    一.嵌入式系统的分区 嵌入式系统部署在Flash设备上时,对于不同SoC和Flash设备,bootloader.kernel.rootfs的分区是不同的.三星S5PV210规定启动设备的分区方案如下: ...