servlet mvc框架中防止静态资源被mvc框架拦截
要配一个default servlet, 以免静态资源被其他servlet处理; 还要再配一个default filter,以免静态资源被其他filter处理 <filter> <filter-name>defaultFilter</filter-name> <filter-class>somepackage.DefaultFilter</filter-class> </filter> <filter-mapping> <filter-name>defaultFilter</filter-name> <url-pattern>favicon.ico</url-pattern> <url-pattern>/js/*</url-pattern> </filter-mapping> <!–其他filter mapping–> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>favicon.ico</url-pattern> <url-pattern>/js/*</url-pattern> </servlet-mapping> <!–……–> <servlet-mapping> <servlet-name>mvcDispatch</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> public class DefaultFilter implements Filter { private RequestDispatcher defaultRequestDispatcher; @Override public void destroy() { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { defaultRequestDispatcher.forward(request, …