1.redirect:action处理完后重定向到一个视图资源(如:jsp页面),请求参数全部丢失,action处理结果也全部丢失。 

2.redirectAction:action处理完后重定向到一个action,请求参数全部丢失,action处理结果也全部丢失。 

3.chain:action处理完后转发到一个action,请求参数全部丢失,action处理结果不会丢失。

redirectAction Result:

    这个Result使用ActionMapperFactory提供的ActionMapper来重定位浏览器的URL来调用指定的action和(可选的)namespace.

    这个Result比ServletRedirectResult要好.因为你不需要把URL编码成xwork.xml中配置的ActionMapper提供的模式.

这就是说你可以在任意点上改变URL模式而不会影响你的应用程序. 因此强烈推荐使用这个Result而不是标准的redirectresult来解决重定位到某个action的情况.

ActionName (默认) - 重定位到的action名 

namespace - action的名称空间. 如果为null,则为当前名称空间

redirectResult:

调用{@link HttpServletResponse#sendRedirect(String)sendRedirect}方法来转到指定的位置. 

HTTP响应被告知使浏览器直接跳转到指定的位置(产生客户端的一个新请求).这样做的结果会使刚刚执行的action(包括action实例,action中的错误消息等)丢失,不再可用. 

这是因为action是建立在单线程模型基础上的.传递数据的唯一方式就是通过Session或者可以为Ognl表达式的web参数(url?name=value)

location (默认) - action执行后跳转的地址. 

parse - 默认为true. 如果设置为false, location参数不会被当作Ognl表达式解析.

<result name="success"type="redirect">/displayCart.action?userId=${userId}</result>

<action   name="delete "   class="com.zeng.action.UserManageAction"   method= "delete"> 

   <result   type="redirect ">list.action?pageBean.pageNumber=${pageBean.pageNumber}</result> 

</action>

*********************************************************************************************************

使用redirect重置链接需要后缀名,使用了redirect——action就不能使用了,

就例如使用chain一样,只需要写action的配置名,如果加入后缀名.action,就会报出异常,action未配置正确。

struts2redirect-action 传递 参数 

    使用struts2框架,在提交一个请求后,将获取的数据对象再要生成一个序列号,为了防止刷新生成冗余序列号,就在请求处理完成后,直接重定向到显示该信息的action中:

<action name="enterpreinfo"class="preinfoBusinessAction" method="enterPreinfoSub">

  <result name="success"type="redirectAction">

    showpreinfo?preinfo.order_number=${preinfo.order_number}&amp;preinfo.company_name=${preinfo.company_name}

 </result>

 <result name="error"type="redirect">

 <paramname="location">/error.jsp</param>

 </result>

</action>

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

在这个配置文件里,多个参数的连接符使用了"&amp;",但XML的语法规范,应该使用"&amp;"代替"&",原理和HTML中的转义相同,开始没有注意,在struts分析配置文件时,总是报出这样的错误:

The reference to entity "preinfo" must end with the ';'delimiter.

?

进行上面说明的替换后,就正常了。

********************************************************************************

今天在用struts2在做项目时候,从一个action我想跳转到另一个action,并且呢得带上值。说说我的做法吧,首先你得在你的第一个action中这个id必须要有set、get方法。 

跳转时你的struts.xml: 

(方法一): 

<result name="topic"type="redirect">/topicAction!findTopics.do?topicId=${topicId}</result> 

(方法二): 

<result name="topic"type="redirectAction"> 

  <paramname="actionName">findTopics</param> 

  <paramname="topicId">${topicId}</param> 

</result>

如果是多个参数的话,继续再加几个<param>就行了,对于(方法一)如果是多个参数的怎么办? 

<result name="topic"type="redirect">/topicAction!findTopics.do?topicId=${topicId}&amp;elementId=${elementId}</result> 

这不就行了。

************************************************************************************

This is how I should do it

@Results({ 

   @Result(name="input", type="redirectAction", params = {"actionName", "resend"}) 

})

*************************************************************************************

http://corradignw.javaeye.com/blog/355717

struts2.1.6无论是xml还是annotation配置redirectAction时,如果要传一些参数,

可是这些参数在ServletActionRedirectResult并没有声明,这时ognl会抛异常出来。

但实际上传值是成功的。详见struts2的jira: 

例: 

Java代码 

@Results({   

   @Result(name="reload",type="redirectAction"  

   ,params={"actionName","hello_world"  

           ,"namespace","/center/part1"  

           ,"id","09"  

           ,"count","90"})   

})

@Results({

   @Result(name="reload",type="redirectAction"

 ,params={"actionName","hello_world"

     ,"namespace","/center/part1"

     ,"id","09"

     ,"count","90"})

})

把日志级别调高也不管用,好像还没有什么解决办法。

****************************************************************************************
dispatcher结果类型为缺省的result类型,用于返回一个视图资源(如:jsp) 

Xml代码 :

<resultname="success">/main.jsp</result> 

<resultname="success">/main.jsp</result> 

以上写法使用了两个默认,其完整的写法为: 

   <resultname="success"type="dispatcher"> 

    <paramname="location">/maini.jsp</param> 

</result> 
location只能是页面,不能是另一个action(可用type="chain"解决)。

redirect结果类型用于重定向到一个页面,另一个action或一个网址。 

Xml代码:

<result name="success"type="redirect">aaa.jsp</result> 

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

<result name="success"type="redirect">www.baidu.com</result>

redirectAction结果类型使用ActionMapperFactory提供的ActionMapper来重定向请求到另外一个action 

Xml代码:

<result name="err"type="redirecAction"> 

   <paramname="actionName">重定向的Action名</param> 

    <paramname="namespace">重定向Action所在的名字空间</param> 

</result> 
redirect和redirectAction两种结果类型在使用上其实并没有什么区别,只是写法不同而已。

chain用于把相关的几个action连接起来,共同完成一个功能。 

Xml代码:

<action name="step1"class="test.Step1Action"> 

    <result name="success"type="chain">step2.action</result> 

</action> 

<action name="step2"class="test.Step2Action"> 

<resultname="success">finish.jsp</result> 

</action> 

处于chain中的action属于同一个http请求,共享一个ActionContext 

  
plaintext结果类型用于直接在页面上显示源代码

Xml代码:

<result name="err"type="plaintext">

<paramname="location">具体的位置</param> 

   <paramname="charSet">字符规范(如GBK)</param> 

</result>

配置文件Struts.xml 中type属性 redirect,redirectAction,chain的区别的更多相关文章

  1. struts2配置文件(struts.xml)中相关属性的设置

    <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-/ ...

  2. struts2之配置文件struts.xml详解

    struts配置文件 struts.xml配置参数详解 struts.xml中很大一部分配置默认配置就好了 但是有些还是需要做了解  以便于理解 和修改 <?xml version=" ...

  3. 在Struts.xml中的result元素指的是:指定动作类的动作方法执行完后的结果视图.

    result结果集 上一篇文章主要讲Struts2框架(4)---Action类访问servlet这篇主要讲result结果集 在Struts.xml中的result元素指的是:指定动作类的动作方法执 ...

  4. Struts2笔记1:--Struts2原理、优点、编程流程、6大配置文件以及核心配置文件struts.xml

    Struts2原理(底层使用的是Servlet的doFilter方法): Struts2优点: 第一个Struts程序: 在开发Struts程序之前,首先要导入额外的jar包,基本需求的是14个jar ...

  5. struts2配置文件struts.xml的简介

    本文在于总结,深入研究有别人写的很好了,也没必要再去写,将在本文后面附上他们的文章地址: 一.struts2的执行过程: 二.struts2的配置文件struts.xml 下面是其三大部分includ ...

  6. Mybatis配置文件SqlMapConfig.xml中的标签

    SqlMapConfig.xml配置文件中的属性 1 配置内容 properties(属性) settings(全局配置参数) typeAliases(类型别名) typeHandlers(类型处理器 ...

  7. struts2总结三:struts2配置文件struts.xml的简单总结

    一.struts中的常量constant的配置. 在struts2中同一个常量的配置有三种方式,第一种在struts.xml中,第二种在struts.properties中配置,第三种在web.xml ...

  8. struts.xml中出现Package struts2 extends undefined package struts-default解决办法

    在struts.xml中出现extends undefined package struts-default,经过查阅资料原来是因为没有联网的缘故.这样解决:在myeclipse中关联本地的dtd文件 ...

  9. struts.xml中出现extends undefined package struts-default解决的方法

    在struts.xml中出现extends undefined package struts-default,经过查阅资料原来是由于没有联网的缘故. 这样解决:在myeclipse中关联本地的dtd文 ...

随机推荐

  1. JMeter接口测试和压力测试

    JMeter接口测试和压力测试 JMeter可以做接口测试和压力测试.其中接口测试的简单操作包括做http脚本(发get/post请求.加cookie.加header.加权限认证.上传文件).做web ...

  2. jQuery 3D垂直多级菜单

    在线演示 本地下载

  3. Git使用的常用命令

    一.git工作流程 Workspace工作区:是当前工作目录,可以在此目录编辑文件 Index缓存区:add指令,保存文件的改动 Repository仓库:commit指令,将多次的文件改动最后提交 ...

  4. iOS基于XMPP实现即时通讯之一、环境的搭建

    移动端访问不佳,请访问我的个人博客 使用XMPP已经有一段时间了,但是一直都没深入研究过,只是使用SDK做一些简单的操作,看了许多大神的博客,自己总结一下,准备写一系列关于XMPP的使用博客,以便于自 ...

  5. DPDK l2fwd

    dpdk的l2fwd主要做二层转发,代码分析如下. #include <stdio.h> #include <stdlib.h> #include <string.h&g ...

  6. linux top ps 命令

    http://javawind.net/p131 VIRT:virtual memory usage 虚拟内存1.进程“需要的”虚拟内存大小,包括进程使用的库.代码.数据等2.假如进程申请100m的内 ...

  7. NFV及vIMS的部署实施

    随着5G和物联网等领域的快速发展,移动数据业务飞速增长,而传统电信网络基于专用硬件的架构和封闭式的网元,已经成为运营商拓展新业务的严重障碍.NFV能够根据用户和业务需求灵活动态地进行网络资源配置,实现 ...

  8. php变量简单介绍

    1.isset() 判断变量是否存在 ==================================================================== 2.unset()清除变 ...

  9. HTTP Status 500 - javax.el.PropertyNotFoundException: Property 'lkmId' not found on type cn.itcast.entity.LinkMan

    报错 type Exception report message javax.el.PropertyNotFoundException: Property 'lkmId' not found on t ...

  10. 负载均衡之DNS域名解析

    转载请说明出处:http://blog.csdn.net/cywosp/article/details/38017027 在上一篇文章(http://blog.csdn.net/cywosp/arti ...