一、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. redis api-set

  2. CH8 IO库

    8.1 #include <iostream> #include <string> #include <sstream> #include <fstream& ...

  3. kali打开networkmanager

    有时候可能在用网卡时,或者是其他情况下关闭了networkmanager,而要管理网络这个又是必须的,需要我们手动打开. 没有网络管理器是这样的: 有管理器是这样的: 不多废话了,用命令/etc/in ...

  4. Django(十九)文件上传:图片上传(后台上传、自定义上传)、

    一.基本设置 参考:https://docs.djangoproject.com/zh-hans/3.0/topics/http/file-uploads/ 1)配置project1/settings ...

  5. Redis之datatype概述

    Redis支持的数据类型     String     List    Set    Sorted Set    Hashes    Bit array    HyperLogLog     Bina ...

  6. linux安装软件的几种方法----linux下编译安装软件的一般步骤

    linux安装软件的几种方法: 一.rpm包安装方式步骤: 1.找到相应的软件包,比如soft.version.rpm,下载到本机某个目录: 2.打开一个终端,su -成root用户: 3.cd so ...

  7. vs2010编译C++ 运算符

    // CTest.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #include &l ...

  8. CentOS configuration uses the SFTP server

    SFTP,即 SSH 文件传输协议( SSH File Transfer Protocol ),或者说是安全文件传输协议( Secure File Transfer Protocol ).SFTP 是 ...

  9. 剑指offer 链表中环的入口位置

    题目描述 一个链表中包含环,请找出该链表的环的入口结点.   思路:这题需要知道a = c,然后head和slow每次走一步,相遇的时候就是第一个入口交点, 注意:for循环或者while循环之后,一 ...

  10. hook框架frida的安装以及简单实用案例

    1.下载地址 https://github.co/frida/frida/releases 2.另外两种安装方法 1.Install from prebuilt binaries This is th ...