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. 如何写出优雅的 Golang 代码

    原文: https://draveness.me/golang-101.html Go 语言是一门简单.易学的编程语言,对于有编程背景的工程师来说,学习 Go 语言并写出能够运行的代码并不是一件困难的 ...

  2. 给定制的vuejs组件添加v-model双向绑定支持

    用过vuejs的前端工程师,对于v-model一定印象深刻.它向类似textarea,input等原生html原生添加双向数据绑定的能力非常方便.但是对于你的定制vue组件并不是能够直接应用v-mod ...

  3. Redis之缓存雪崩、缓存穿透、缓存预热、缓存更新、缓存降级

    目录 Redis之缓存雪崩.缓存穿透.缓存预热.缓存更新.缓存降级 1.缓存雪崩 2.缓存穿透 3.缓存预热 4.缓存更新 5.缓存降级 Redis之缓存雪崩.缓存穿透.缓存预热.缓存更新.缓存降级 ...

  4. Redis安装和基本使用

    目录 Redis安装和基本使用 安装 配置 启动服务端 启动客户端 Redis键(key) 与键相关的基本命令 Redis字符串 常用字符串命令: Redis哈希 常用Hash命令 Redis 列表( ...

  5. 双栈(Dual Stack)

    参考博客: 双栈数据结构: https://blog.csdn.net/hebtu666/article/details/83011115 https://blog.csdn.net/cainv89/ ...

  6. 锁、分布式锁、无锁实战全局性ID

    1.为什么要使用锁 当发生并发时,会产生多线程争夺一个资源,为保证资源的唯一性. JVM锁:对象锁,死锁,重入锁,公平锁,偏向锁 分布式锁:数据库 nosql .zookeeper 面试题:如何排查死 ...

  7. HTTP Status 406 – Not Acceptable

    前端调用这个方法报错: HTTP Status 406 – Not Acceptable Type Status Report Description The target resource does ...

  8. 简明conda使用指南

    目录 区分conda, anaconda, miniconda conda版本 虚拟环境 分享环境 查看某个环境的位置 列出软件包 安装软件包 删除软件包 查找软件包 conda配置 conda实践: ...

  9. C 语言实现回调函数

    优点 不需要改变调用的主函数,只需添加命令和相应函数. #include "stdio.h" #include "stdlib.h" #include &quo ...

  10. pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1,512,1,1])

    1.pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.S ...