一、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. JDBC--获取数据库连接

    1.JDBC(Java Database Connectivity)是一个独立于特定数据库管理系统.统一的sQL数据库存取和操作的公共接口. 2.Java中的几种数据库存取技术: --1)JDBC直接 ...

  2. Linux环境安装Golang

    命令行安装 yum install golang 默认安装目录/usr/lib/golang/  (不同系统不一样,可通过搜索golang关键字查找: find / -name golang) 卸载 ...

  3. Pycharm 报错 Environment location directory is not empty 解决

    新电脑clone项目后发现Project Interpreter无法配置, New environment 选择后无法应用, 鼠标悬停在Location 提示 Environment location ...

  4. IEEE Spectrum 2014年十大编程语言盘点

    近日,IEEE Spectrum推出 了一个最流行的编程语言排行榜.排行榜筛选了 12 项指标,综合了 10 个来源(含 IEEE Xplore.Google.GitHub)的数据,最终评选出了下面这 ...

  5. 拖放获取文件信息的bat代码

    参考:岁月如歌-通过拖曳获取文件信息的bat代码 拖放获取文件信息的bat代码 使用命令行配合7z解压文件时由于每次解压的文件不同,因此搜索了一下拖放识别文件信息的方法,以此方式来减轻工作量 获取文件 ...

  6. 安装ruby的一些坑

    之前一直下载不下来.是因为需要翻墙.

  7. phpStudy隐藏后门预警

    1.事件背景 近日,使用广泛的PHP环境集成程序包phpStudy被公告疑似遭遇供应链攻击,程序包自带PHP的php_xmlrpc.dll模块隐藏有后门,安恒应急响应中心和研究院随即对国内下载站点提供 ...

  8. Java笔记--常用类

    1.String类: --使用Unicode字符编码,一个字符占两个字节: --String类是一个final类,代表不可变的字符序列: --字符串是不可变的,一个字符串对象一旦被配置,其内容是不可变 ...

  9. 0109 springboot的部署测试监控

    springboot的部署测试监控 部署 基于maven 打包 JAR 打包方式一般采用的jar包,使用springboot的默认方式即可: 使用maven命令: mvn clean package ...

  10. HTML 5 <blockquote><p>的分工与合作

    一提到文档标签,大家首先想到的就是p,那如果要实现缩进及间距,还得使用margin,padding及text-indent等css样式. 但现在html5的一个新标签解决了以上所有问题,它可以自缩进和 ...