/*
是不支持正则表达式的
实际上重写cacheFilter即可实现
代码如下
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { if (log.isInfoEnabled()) { log.info("OSCache: filter in scope " + cacheScope); } ///////////////////////////// if( !needCachePage((HttpServletRequest)request) ){ chain.doFilter(request, response); return; } // avoid reentrance (CACHE-128) and check if request is cacheable if (isFilteredBefore(request) || !isCacheableInternal(request)) { chain.doFilter(request, response); return; }
needCachePage()函数如下
public static void main(String[] args) { System.out.println("/o2o/product_1.do".matches("/o2o/product_\\d+\\.do")); }
当然这只是个demo 可以替换成自己的正则表达式与请求路径对比即可