我正在将基于 Servlet 2.5 的 webapp 迁移到 Servlet 3.0 并遇到了这个问题,我不知道如何将这些不同的过滤器映射压缩到@WebFilter
该类的一个注释中。
过滤器:
<!-- Day is 12 hours, so if we update at night the new content will be fetched first thing in the morning -->
<filter>
<filter-name>CacheForDay</filter-name>
<filter-class>x.web.client.filter.CacheHeaderFilter</filter-class>
<init-param>
<param-name>CacheTime</param-name>
<param-value>43200</param-value>
</init-param>
</filter>
<filter>
<filter-name>CacheForWeek</filter-name>
<filter-class>x.web.client.filter.CacheHeaderFilter</filter-class>
<init-param>
<param-name>CacheTime</param-name>
<param-value>604800</param-value>
</init-param>
</filter>
<filter>
<filter-name>CacheForMonth</filter-name>
<filter-class>x.web.client.filter.CacheHeaderFilter</filter-class>
<init-param>
<param-name>CacheTime</param-name>
<param-value>18144000</param-value>
</init-param>
</filter>
<filter>
<filter-name>noCache</filter-name>
<filter-class>x.web.client.filter.CacheHeaderFilter</filter-class>
<init-param>
<param-name>CacheTime</param-name>
<param-value>0</param-value>
</init-param>
</filter>
过滤器映射:
<filter-mapping>
<filter-name>CacheForDay</filter-name>
<url-pattern>*.png</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CacheForDay</filter-name>
<url-pattern>*.gif</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CacheForDay</filter-name>
<url-pattern>*.js</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CacheForDay</filter-name>
<url-pattern>*.css</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CacheForMonth</filter-name>
<url-pattern>*.ico</url-pattern>
</filter-mapping>
我该如何替换它们@WebFilter
?