一、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. 深度解析标点符号在Report写作中的应用

    准确的标点符号和大写字母可以帮助Tutor准确理解report的意思.标点符号的某些方面,例如使用逗号,可以是一种个人风格,在引号中正确的标点符号是至关重要的.在前面的一些文章当中我们也给大家说了re ...

  2. 记一次海洋cms任意代码执行漏洞拿shell(url一句话)

    实验环境:海洋CMS6.54(后续版本已该洞已补) 1.后台登录尝试 这个站点是个测试站,站里没什么数据. 进入admin.php,是带验证码的后台登录系统,没有验证码的可以用bp爆破.有验证码的也有 ...

  3. Jackson自定义反序列化

    // 设置jackson时间反系列化格式 SimpleModule module = new SimpleModule(); module.addDeserializer(Date.class, ne ...

  4. 七:日期类Date、日期格式化SimpleDateFormat、日历Calendar

    日期的格式转换:

  5. NO19 优化Linux系统--重要开机自启动服务--关闭自启动项

    **如何优化Linux系统: 1   不用root,添加普通用户,通过sudo授权管理.2   更改默认的远程连接SSH服务端口及禁止root用户远程连接.3   定时自动更新服务器时间.4   配置 ...

  6. 水费管理系统-ER图和流程图

    ER图:

  7. 实践 Network Policy 【转】

    为了演示 Network Policy,我们先部署一个 httpd 应用,其配置文件 httpd.yaml 为: httpd 有三个副本,通过 NodePort 类型的 Service 对外提供服务. ...

  8. 猎鹰9火箭(Falcon 9)

    翻译自:https://www.spacex.com/falcon9 使用了有道词典的翻译,以及本人的修正. 猎鹰9号是SpaceX公司设计和制造的两级火箭,用于可靠和安全地将卫星和“龙”号宇宙飞船送 ...

  9. 014、Java中byte自动转型的操作

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

  10. 利用jQuery实现PC端href生效,移动端href失效

    今天要写一个功能,记录一下吧.if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){ $('.item-a').attr('href' ...