title: Spring interceptions not working
body: <p>I know that this have been asked a lot of times, but none of them could make my code work. I might be doing something wrong but I can't find out what.</p>
  
  <p>I'm using Spring Boot with AngularJS, what I'm trying to do is to preHandle all the requests.</p>
  
  <p>This is my code:</p>
  
  <p>Controller:</p>
  
  <pre><code>@RestController
  @RequestMapping(value = { "/user" })
  public class UserController {
  
      @RequestMapping(value = "/get", method = RequestMethod.GET)
      public String getLanguage() {
          return "user";
      }
  }
  </code></pre>
  
  <p>Interceptor: </p>
  
  <pre><code>@Component
  public class RequestHandler extends HandlerInterceptorAdapter {
  
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException {
        System.out.println("intercepted");
        return false;
    }
  }
  </code></pre>
  
  <p>WebConfig:</p>
  
  <pre><code>@Configuration
  public class WebConfig extends WebMvcConfigurerAdapter {
  
    @Autowired
    HandlerInterceptor requestHandler;
  
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
      registry.addInterceptor(requestHandler);
    }
  }
  </code></pre>
  
  <p>And I added this to the applicationContext.xml:</p>
  
  <pre><code>&lt;mvc:interceptors&gt;
      &lt;bean class="server.RequestHandler" /&gt;
  &lt;/mvc:interceptors&gt;
  </code></pre>
  
  <p>I've been all the weekend trying to make this work and I couldn't, any help will be really appreciated!</p>
  
  <p>Thank you!</p>