title: How to get Path Variables in Spring Filter?
body: <p>I am working on a security filter that needs to do some checks based on the value of the path variable. 
  I was trying to do smth like this:</p>
  
  <p><code>final Map&lt;String, String&gt; pathVariables = (Map&lt;String, String&gt;) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
  </code></p>
  
  <p>But the map is always empty, it looks like my filter has higher precedence than the <code>RequestMappingHandlerMapping</code> that is populating <code>URI_TEMPLATE_VARIABLES_ATTRIBUTE</code> attribute in request.</p>
  
  <p>I have tried adding following config:</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  public class WebConfiguration {
  
      @Bean
      public RequestMappingHandlerMapping requestMappingHandlerMapping() {
          RequestMappingHandlerMapping requestMappingHandler = new RequestMappingHandlerMapping();
          requestMappingHandler.setOrder(0);
          return requestMappingHandler;
      }
  }
  </code></pre>
  
  <p>It doesn't help, filters are executed prior to <code>RequestMappingHandlerMapping</code> gets called.</p>
  
  <p>relative path example:
  <code>/user/{uid}/action</code></p>
  
  <p>I have several paths in my controller. All of them have <code>uid</code> path var in the path, but some paths have them set not in the same order, some paths have more than 1 variable.</p>
  
  <p>In my security filter I fetch Auth header, decrypt it, fetch <code>userId</code> from it and compare it with path var value. If those ids do not match I return 403.</p>
  
  <p>I am wondering if it is possible to override the order of those 2 actions.
  Or, maybe, there is some other way of inspecting path variables in filters?</p>