李李的技术博客

  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 李李 阅读(1504) 评论(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
  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: