Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The standard Servlet API doesn't support this facility. You may want either to use a rewrite-URL filter for this like <a href="http://tuckey.org/urlrewrite/" rel="noreferrer">Tuckey's one</a> (which is much similar Apache HTTPD's <code>mod_rewrite</code>), or to add a check in the <code>doFilter()</code> method of the Filter listening on <code>/*</code>.</p> <pre><code>String path = ((HttpServletRequest) request).getRequestURI(); if (path.startsWith("/specialpath/")) { chain.doFilter(request, response); // Just continue chain. } else { // Do your business stuff here for all paths other than /specialpath. } </code></pre> <p>You can if necessary specify the paths-to-be-ignored as an <code>init-param</code> of the filter so that you can control it in the <code>web.xml</code> anyway. You can get it in the filter as follows:</p> <pre><code>private String pathToBeIgnored; public void init(FilterConfig config) { pathToBeIgnored = config.getInitParameter("pathToBeIgnored"); } </code></pre> <p>If the filter is part of 3rd party API and thus you can't modify it, then map it on a more specific <code>url-pattern</code>, e.g. <code>/otherfilterpath/*</code> and create a new filter on <code>/*</code> which forwards to the path matching the 3rd party filter.</p> <pre><code>String path = ((HttpServletRequest) request).getRequestURI(); if (path.startsWith("/specialpath/")) { chain.doFilter(request, response); // Just continue chain. } else { request.getRequestDispatcher("/otherfilterpath" + path).forward(request, response); } </code></pre> <p>To avoid that this filter will call itself in an infinite loop you need to let it listen (dispatch) on <code>REQUEST</code> only and the 3rd party filter on <code>FORWARD</code> only.</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/13521946/how-to-prevent-static-resources-from-being-handled-by-front-controller-servlet-w">How to prevent static resources from being handled by front controller servlet which is mapped on /*</a></li> <li><a href="https://stackoverflow.com/questions/1483063/spring-mvc-3-and-handling-static-content-am-i-missing-something">How to handle static content in Spring MVC?</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload