title: How can I inject HttpServletRequest attributes (set in interceptor) in my controller?
body: <p>I want to add an attribute to all my requests before they reach the controller.</p>
  
  <p>What I am using : </p>
  
  <pre><code>@Component
  public class SessionValidatorInterceptor implements HandlerInterceptor {
  
  @Override
  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
          throws Exception {
      .... some code ....
      request.setAttribute("validRequest","true");
      .... more code ...
      return true;
  }
  </code></pre>
  
  <p>Now to get this attribute in my rest controller I am doing :</p>
  
  <pre><code>public ResponseEntity&lt;?&gt; someMethod(HttpServletRequest request){
      request.getAttribute("validSession");
      ...
  </code></pre>
  
  <p>My question is can I do this more elegantly like @RequestParam("validSession")  or @PathVariable or something else?
  Can Spring do this for me ?</p>
  
  <p>Appreciate any help.</p>