李李的技術博客

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            13 隨筆 :: 0 文章 :: 61 評論 :: 0 Trackbacks

          一個例子,原來的

          <interceptor-ref name="validation"/>
          <interceptor-ref name="workflow"/>

          可改寫為
          <interceptor-ref name="validation">
              <param name="excludeMethods">input,back,cancel</param>
          </interceptor-ref>
          <interceptor-ref name="workflow">
              <param name="excludeMethods">input,back,cancel</param>
          </interceptor-ref>

          那么,對于簡單的需驗證頁面,不需要再因為避免不必要的校驗而分兩個action。

          只有com.opensymphony.xwork.validator.ValidationInterceptor, com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor 定義并實現了這個excludeMethods,實現的也還是比較粗糙的,我們在做類似實現的時候可以參考一下,有必要也可以改進,擴展一下,例如增加includeMethods
              public void setExcludeMethods(String excludeMethods) {
                  
          this.excludeMethods = TextParseUtil.commaDelimitedStringToSet(excludeMethods);
              }

              
          public String intercept(ActionInvocation invocation) throws Exception {
                  
          if (excludeMethods.contains(invocation.getProxy().getMethod())) {
                      log.debug(
          "Skipping workflow. Method found in exclude list.");
                      
          return invocation.invoke();
                  }
                  
              }
          posted on 2005-12-03 22:29 李李 閱讀(1531) 評論(2)  編輯  收藏 所屬分類: 技術

          評論

          # re: Webwork2.2的一個改進,Interceptor增加excludeMethods方法 2005-12-04 00:17 scud(飛云小俠)
          太棒了!   回復  更多評論
            

          # re: Webwork2.2的一個改進,Interceptor增加excludeMethods方法 2005-12-04 00:36 scud(飛云小俠)
          引用了一下,多謝 :)

          http://www.jscud.com/srun/news/viewhtml/4_2005_12/164.htm
            回復  更多評論
            

          主站蜘蛛池模板: 息烽县| 贵阳市| 玉树县| 开封县| 泰和县| 酉阳| 冷水江市| 兴城市| 化州市| 察隅县| 济阳县| 筠连县| 体育| 固镇县| 苏州市| 盐城市| 游戏| 三河市| 乡宁县| 青浦区| 离岛区| 垣曲县| 青龙| 马尔康县| 长垣县| 邵武市| 类乌齐县| 盐亭县| 临漳县| 鄂州市| 岳普湖县| 钟山县| 金乡县| 措美县| 车险| 北安市| 闸北区| 泰州市| 阿城市| 绥宁县| 潮安县|