李李的技術博客

            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 李李 閱讀(1533) 評論(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
            回復  更多評論
            

          主站蜘蛛池模板: 张家港市| 五原县| 福清市| 冕宁县| 宁陕县| 遵义县| 延安市| 仪征市| 龙里县| 大名县| 隆回县| 临澧县| 北碚区| 湘潭县| 福鼎市| 温州市| 昆山市| 玉龙| 玉门市| 大渡口区| 嵩明县| 分宜县| 佛学| 兴安县| 大英县| 赤峰市| 古丈县| 古交市| 金川县| 双鸭山市| 遵义县| 遵化市| 沐川县| 于田县| 含山县| 株洲县| 达州市| 望谟县| 纳雍县| 新竹市| 汉阴县|