在Java web开发中常会使用到功能强大的过滤器,他毕竟能给我们带来很大的方便,但是针对过滤的资源我们需要详细的了解他们在web.xml中的配置信息。这个根据几种常用的不同情况进行了总结:
1。如果要映射过滤应用程序中所有资源:
<filter>
<filter-name>loggerfilter</filter-name>
<filter-class>myfilter.LoggerFilter</filter-class>
</filter>
<filter-mapping>
<url-pattern>/*</url-pattern>
</filter-mapping>
2.过滤指定的类型文件资源