一、result:chain(从一个Action转发到另一个Action)

chain结果类型有4个属性,分别是:

actionName (default) - the name of the action that will be chained to

namespace - used to determine which namespace the Action is in that we're chaining. If namespace is null, this defaults to the current namespace

method - used to specify another method on target action to be invoked. If null, this defaults to execute method

skipActions - (optional) the list of comma separated action names for the actions that could be chained to

eg:

public String hotGoods() {

      try {
        QueryRule queryRule=QueryRule.getInstance();
        queryRule.addEqual("isNew", "0");
        List<ProductInfo> productInfoList = geProductInfoService.queryGeProductInfoByQueryRule(queryRule);                                               
        super.getRequest().setAttribute("productInfoList ", productInfoList );
        }catch (Exception e) {

                       e.printStackTrace();

         }
        return SUCCESS;

        }

      <action name="hotGoods" class="listAction" method="hotGoods">
        <result name="success" type="chain">hotGoods1</result>
      </action    

      public String hotGoods1() {
        try {
          List<ProductInfo> productInfoList = (List<ProductInfo>)super.getRequest().getAttribute("productInfoList ");
          super.getRequest().setAttribute("productInfoList ", productInfoList );
          } catch (Exception e) {
              e.printStackTrace();
          }
            return SUCCESS;

          }

      <action name="hotGoods1" class="listAction" method="hotGoods1">
        <result name="success">index.jsp</result>
      </action>

     index.jsp可以得到productInfoList 的值

 二、result:redirect(从一个Action转发到另一个Action)

    public String getFamilyCardUrl() {
      try {
      familyCardWeixinURL = “*****”;

      //familyCardWeixinURL内容为*****.getFamilyCardOpenId.do?code=code&****
      return "familyCardWeixinURL";
      } catch (Exception e) {
      e.printStackTrace();
      }
      return "fail";
      }

      <action name="getFamilyCardOpenId" class="**Action" method="getFamilyCardOpenId">
        <result name="familyCardWeixinURL" type="redirect">${familyCardWeixinURL}</result>
        <result name="fail" type="redirect">/common/500Phone.jsp</result>
      </action>

      getFamilyCardOpenId所在action中需要有全局变量familyCardWeixinURL及其get,set方法

//未完成

关注公众号:CS尼克。我们一起学习计算机相关知识

struts2 result随笔的更多相关文章

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

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

  2. Struts2(result 流 )下载

    jsp: <body> <a href="stream.action?fileName=psb.jpg">psb</a> <br> ...

  3. struts2 result type类型

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

  4. Struts2 result type(结果类型)

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

  5. Struts2 result type

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

  6. struts2 result的type属性

    目前只使用过以下3种,都是直接跳转到另一个action  chain: 写法:<result name="success" type="chain"> ...

  7. struts2 result type的类型

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

  8. struts2 result type属性说明

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

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

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

随机推荐

  1. 080、Java数组之二维数组的定义及使用

    01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...

  2. Spring JMSTemplate 与 JMS 原生API比较

    博客分类: JMS Spring 2.x   JMSUtil与Spring JmsTemplate的对比 Author:信仰 Date:2012-4-20 未完待续,截止日期2012-4-20 从以下 ...

  3. OTF格式

    OTF, OpenType 字体文件. OpenType也叫Type 2字体,是由Microsoft和Adobe公司开发的另外一种字体格式.它也是一种轮廓字体,比TrueType更为强大,最明显的一个 ...

  4. mac java 装机清单

    1. JDK8 2. Eclipse IDE for Enterprise Java Developers 3. maven 4. Postman 5. VS Code 6. finalshell ( ...

  5. Python 实现远程服务器批量执行命令

    paramiko 远程控制介绍 Python paramiko是一个相当好用的远程登录模块,采用ssh协议,可以实现linux服务器的ssh远程登录.首先来看一个简单的例子 import parami ...

  6. vSphere HA 原理与配置

    内容预览: 1. vSphere HA 概述 2. vSphere HA 提供的保护级别 3. vSphere HA运行原理 4. vSphere HA 故障支持场景 5. vSphere HA接入控 ...

  7. 微信小程序IOS真机调试发生了SSL 错误,无法建立与该服务器的安全连接

    小程序 真机调试 IOS request:fail 发生了SSL 错误,无法建立与该服务器的安全连接,解决方法服务器中打开Powerhell,执行以下代码,然后重启服务器 # Enables TLS ...

  8. 剑指offer 把字符串转化为整数

    题目描述 将一个字符串转换成一个整数,要求不能使用字符串转换整数的库函数. 数值为0或者字符串不是一个合法的数值则返回0 输入描述: 输入一个字符串,包括数字字母符号,可以为空 输出描述: 如果是合法 ...

  9. Hibernate(十)--spring整合hibernate

    结构: Spring和Hibernate整合借助于HibernateTemplate applicationContext.xml <?xml version="1.0" e ...

  10. PHP中strlen和mb_strlen函数的使用方式的不同

    (1)strlen  获取字符串长度 (2)mb_strlen  使用方法:   int mb_strlen ( string $str [, string $encoding ] )返回给定的字符串 ...