I am using spring mvc and I need to exclude urls from filter-mapping. It means, I have static content like pictures and css and js ... and I need to not process these request, for example from security filter. I tried urlrewrite, but I was not able to redirect the urls directly to defaultServlet, which is defined in catalina web.xml. I need to jump over filters, because I have a lot of them. Is there a way? Thanks
EDIT - I thought maybe I could create filter which will if decided jump over other filters and execute the servlet at the end. Is it possible to do that? Thanks
By default, filters doesn't support excluding a specific URL pattern, whenever you define a URL pattern for a filter then any request matching this pattern is handled by the filter without exceptions. The simplest way for excluding URLs from a filter is to map your filter to a very specific pattern.
Exclude sites from your search engine:In the Basics tab, click Advanced under Sites to Search to expand the Sites to exclude section. Click Add under Sites to exclude. Enter the URL you want to exclude and select whether you want to include any pages that match or only that specific page.
The url-pattern element of a servlet-mapping or a filter-mapping associates a filter or servlet with a set of URLs. When a request arrives, the container uses a simple procedure for matching the URL in the request with a url-pattern in the web. xml file.
In the end I used:
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>Warn</param-value>
</init-param>
</filter>
and url rewrite was defined:
<urlrewrite default-match-type="wildcard">
<rule>
<from>/static/**</from>
<to>/static/$1</to>
</rule>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With