目前只使用过以下3种,都是直接跳转到另一个action

 chain:

写法:<result name="success" type="chain">nextAction</result>

nextAction前面不加【/】斜线,上一个action中request中设置的值,在nextAction中可以取到

redirect:

写法:<result name="success" type="redirect">nextAction</result>

nextAction前面加或不加【/】斜线都可以,上一个action中request中设置的值,会丢失,在nextAction中无法取到

但是可以使用【?】问号传参,注意【&】使用【&amp;】代替

<result name="success" type="redirect">nextAction?nextForm.property=${currentForm.property}&amp;nextForm.property=${current.property}</result>

nextAction中必须有nextForm的get和set方法,如果是属性的话也必须有get和set方法,才能取到值

private NEXTForm nextForm= new NEXTForm ();
public NEXTForm getNextForm() {
return nextForm;
}
public void setNextForm(NEXTForm nextForm) {
this.nextForm= nextForm;
}

redirectAction:

写法:<result name="success" type="redirectAction">nextAction</result>

yourAction前面不加【/】斜线,上一个action中request中设置的值,会丢失,在nextAction中无法取到

但是可以使用【?】问号传参,注意【&】使用【&amp;】代替

<result name="success" type="redirect">nextAction?nextForm.property=${currentForm.property}&amp;nextForm.property=${current.property}</result>

nextAction中必须有nextForm的get和set方法,如果是属性的话也必须有get和set方法,才能取到值

private NEXTForm nextForm= new NEXTForm ();
public NEXTForm getNextForm() {
return nextForm;
}
public void setNextForm(NEXTForm nextForm) {
this.nextForm= nextForm;
}

注:redirect与redirect-action区别

一、使用redirect需要后缀名 使用redirect-action不需要后缀名 ,但是在我实际使用时redirect不加后缀名也可以,在同一个包下,不同包没有试过。
二、type="redirect" 的值可以转到其它命名空间下的action,而redirect-action只能转到同一命名空下的 action,因此它可以省略.action的后缀直接写action的名称。

struts2 result的type属性的更多相关文章

  1. struts2简单入门-关于Result标签Type属性的说明

    Result标签 作用 当action执行完毕,后要返回什么样的视图. Type属性 决定返回的是什么视图. struts-default.xml的Type属性的定义 <result-types ...

  2. struts2的result的type属性

    一共有两个属性name和type name这里就不介绍了 type    返回结果的类型,值可以从default-struts.properties中看到看到 常用的值:dispatcher (默认) ...

  3. 学习Struts--Chap04:result中type属性dispatcher、redirect、redirectAction、chain的区别

    1.Struts2框架中常用的结果类型的分析和比较 dispatcher:缺省的result类型,type默认是dispatcher内部转发.如果不写type类型只写一个名字的话,不单是type类型默 ...

  4. [原创]java WEB学习笔记58:Struts2学习之路---Result 详解 type属性,通配符映射

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

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

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

  6. 分享知识-快乐自己:Struts2 - result标签的name属性和type属性

    1):result的name属性   例如:<result name="success">/pages/success.jsp</result> Strut ...

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

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

  8. Struts2 中result type属性说明

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

  9. struts2 result type类型

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

随机推荐

  1. C#显示声名接口就是为了解决方法重名的问题

    class class1 { public static void Main(string[] args) { Person ps = new Person(); ps.KouLan(); IFlya ...

  2. MyEclipse笔记(2):debug的使用

    对于程序代码而言,学会调debug是重中之重,依此,掌握该技巧 以算1到50的和的代码为例: package com.front.action; public class debug { public ...

  3. ionic开发ios app

    注意必须是mac系统 1. 首先要安装node环境,Ionic的安装和后续的许多前端工具的安装都依赖于node的包管理器npm. nodeJs环境的安装很简单,去官网下载最新版的NodeJs直接安装即 ...

  4. QT小插件类之QRoundProgressBar

    QRoundProgressBar类 1. 详细描述 QRoundProgressBar类能够实现一个圆形的进度图表,并且有和QProgressBar类似的API接口 1.1 继承关系 #includ ...

  5. SQL约束脚本的用法

    1.主键约束:要对一个列加主键约束的话,这列就必须要满足的条件就是分空因为主键约束:就是对一个列进行了约束,约束为(非空.不重复)以下是代码   要对一个列加主键,列名为id,表名为emp 格式为:a ...

  6. jq:get获取json数据并以表格形式生成到页面

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  7. npm和gulp学习笔记

    原文链接:[gulpfile.js文件常见配置]

  8. MVC-生成验证码

    1.在网上可以随便找一个生成验证码的类例如: using System; using System.Drawing; using System.Drawing.Imaging; using Syste ...

  9. php DOMDocument 递归 格式化缩进HTML文档

    function format(\DOMNode $node, $treeIndex = 0) { //不格式化的标签 if (in_array($node->nodeName, array(& ...

  10. 向asp.net项目中添加控件AspNetPager

    1.打开项目,把.dll文件放入项目中: 2.在工具栏中添加一个自定义选项卡