Search code examples
springspring-mvcfilterweb.xmlurl-pattern

Multiple <url-pattern> in <filter-mapping> not working


I use several filter in my web.xml of my spring App. some of my filter has multiple url-pattern to act on these urls, likes below:

<filter>
    <display-name>AuditLogFilter</display-name>
    <filter-name>AuditLogFilter</filter-name>
    <filter-class>org.somePackages.log.AuditLogFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>AuditLogFilter</filter-name>
    <url-pattern>/portal/*</url-pattern>
    <url-pattern>/view/*</url-pattern>
    <url-pattern>/rest/**/front</url-pattern>
</filter-mapping>

But i found that the AuditLogFilter don't act on all of these url-patterns. any solution?


Solution

  • I Finally resolve my problem By changing the order of AuditLogFilter to top of my filters in web.xml. In other words, I put <filter> and <filter-mapping> parts in above of my filter definitions instead of end of web.xml file.