你要是只想过滤.do后缀的文件,在<url-pattern>*.do</url-pattern>不就可以了嘛

解决方案 »

  1.   

    也可以这样
     String strURL=new String((httpRequest).getRequestURL());
                 if (strURL.endsWith(".gif")|| strURL.endsWith(".css")||strURL.endsWith(".js") ){
                     chain.doFilter(httpRequest,httpResponse);
                 }
      

  2.   

    感谢你的关注,但如果写成<url-pattern>*.do</url-pattern>那过滤器就会不分private和public目录的都过滤了。
    我现在就是按照你写的那段代码那样写的,但我觉得如果能做到请求.gif,.css时能不通过过滤器这么一道工序就好了。你明白我的意思吗,也就是说不进入过滤器的dofilter方法。
      

  3.   

    感谢你的关注,但如果写成<url-pattern>*.do</url-pattern>那过滤器就会不分private和public目录的都过滤了。
    ---------------------------------------------------------------------------
    应该是这样的,只要是*.do的文件都过滤
    我现在就是按照你写的那段代码那样写的,但我觉得如果能做到请求.gif,.css时能不通过过滤器这么一道工序就好了。你明白我的意思吗,也就是说不进入过滤器的dofilter方法。
    ----------------------------------------------------------------------
    明白你的意思。要不你改下你的方法,应该可以的!