title: Adding parameters to Spring MVC Interceptor
body: <p>I'm trying to achieve authorization for my RestAPI, by letting Spring's Interceptor's (<strong>HandlerInterceptorAdapter</strong>) PreHandle method check wether the user is in the required role, before the scope hits the requested action in the controller. This requires, however, that I provide each action (URL Path) with the ID of the role it requires. This is my current setup:</p>
  
  <pre><code>public class AuthorizationInterceptor extends HandlerInterceptorAdapter{
  
  @Autowired
  IUserService us;
  
      //before the actual handler will be executed
      public boolean preHandle(HttpServletRequest request, 
              HttpServletResponse response, Object handler, Integer roleId)
          throws Exception {
  
          String userId = request.getHeader("UserId");
  
          if(!us.isUserInRole(Long.parseLong(userId), roleId))
              return false;
  
          return true;
  
  
      }
  
  }
  </code></pre>
  
  <p><strong>And (a part of) the servlet-context.xml:</strong></p>
  
  <pre><code>&lt;interceptors&gt;
      &lt;interceptor&gt;   
          &lt;mapping path="/" /&gt;
          &lt;mapping path="/users/**" /&gt;
          &lt;beans:bean class="com.lumi.api.interceptors.AuthorizationInterceptor"&gt;&lt;/beans:bean&gt;
      &lt;/interceptor&gt;
  &lt;/interceptors&gt;
  </code></pre>
  
  <p>My question is, wether I can pass in the parameter <strong>roleId</strong> with the bean in the servlet-context config. I can't seem to find anything in the docs. I think I once saw something like:</p>
  
  <pre><code>&lt;mapping path="/" /&gt;
  &lt;parameter name="something" value="some value"&gt;
  </code></pre>
  
  <p>But i'm not sure.</p>