标签:
url-pattern根据请求path路径进行过滤,servlet-name根据Servlet名称过滤
<filter> <filter-name>CompressingFilter</filter-name> <filter-class> com.utfs.util.compress.CompressingFilter </filter-class> </filter> <filter-mapping> <filter-name>CompressingFilter</filter-name> <url-pattern>*.js</url-pattern> </filter-mapping> <filter-mapping> <filter-name>CompressingFilter</filter-name> <url-pattern>*.css</url-pattern> </filter-mapping> <filter-mapping> <filter-name>CompressingFilter</filter-name> <url-pattern>*.gif</url-pattern> </filter-mapping> <filter-mapping> <filter-name>CompressingFilter</filter-name> <url-pattern>*.png</url-pattern> </filter-mapping> <filter-mapping> <filter-name>CompressingFilter</filter-name> <url-pattern>*.jpg</url-pattern> </filter-mapping> <filter-mapping> <filter-name>CompressingFilter</filter-name> <servlet-name>UmpDispatcherServlet</servlet-name> </filter-mapping> <filter-mapping> <filter-name>CompressingFilter</filter-name> <servlet-name>CodeServlet</servlet-name> </filter-mapping> <filter-mapping> <filter-name>CompressingFilter</filter-name> <url-pattern>/app/*</url-pattern> </filter-mapping>
另外需要了解,在Filter中除了使用sendRedirect之外无法进行请求转发
J2EE Filter配置项url-pattern与servlet-name
标签:
原文地址:http://my.oschina.net/ososchina/blog/531255