zoukankan      html  css  js  c++  java
  • struts2 result随笔


        一、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尼克。我们一起学习计算机相关知识

  • 相关阅读:
    python 线程队列PriorityQueue(优先队列)(37)
    python 线程队列LifoQueue-LIFO(36)
    python线程队列Queue-FIFO(35)
    python线程障碍对象Barrier(34)
    关于mybatis 在C#.Net中批量增,删,改
    c#如实现将一个数字转化为其他进制字符串输出
    Tostring(); 括号中的参数 格式化字符串
    前端笔记之HTML5&CSS3(上)新特性&音频视频&本地存储&自定义属性
    前端笔记之jQuery(下)事件&节点操作&净位置&拖拽&页面卷动值&遍历JSON
    前端笔记之jQuery(上)加载函数的区别&对象&操作HTML/CSS&动画&选择器
  • 原文地址:https://www.cnblogs.com/shueixue/p/5709954.html
Copyright © 2011-2022 走看看