title: Spring MVC Handler Interceptor does not run
body: <p>I have following interceptor class :</p>
  
  <pre><code>package cz.coffeeexperts.feedback.server.web.interceptors;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
  
  public class RestAuthorizationInterceptor extends HandlerInterceptorAdapter {
  
      @Override
      public boolean preHandle(HttpServletRequest request, 
              HttpServletResponse response, Object handler)
          throws Exception {
  
          System.out.println("fuu");
          response.setStatus( HttpServletResponse.SC_UNAUTHORIZED );
          return false;
      }
  }
  </code></pre>
  
  <p>I configured it inside my spring-webmvc.xml as following :</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns:mvc="http://www.springframework.org/schema/mvc"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"&gt;
  
      &lt;mvc:annotation-driven/&gt;
  
      &lt;mvc:interceptors&gt;
       &lt;mvc:interceptor&gt;
         &lt;mvc:mapping path="/rest/api/01/status" /&gt;
         &lt;bean class="cz.coffeeexperts.feedback.server.web.interceptors.RestAuthorizationInterceptor" /&gt;
       &lt;/mvc:interceptor&gt;
      &lt;/mvc:interceptors&gt;     
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>However when I go to <code>http://localhost:8080/myserver/rest/api/01/status</code>, I get regular answer with status code 200 (same as before I added interceptor). Also, message "fuu" is not printed (so the preHandle method is not called).</p>
  
  <p>Any ideas? I started to do it with this example : <a href="http://javapapers.com/spring/spring-mvc-handler-interceptor/" rel="nofollow">http://javapapers.com/spring/spring-mvc-handler-interceptor/</a>, but all other examples look the same, I cant find where I go wrong.</p>
  
  <p>I am using Spring <code>3.2.4.RELEASE</code></p>
  
  <hr>
  
  <p>Important edit, it works with this :</p>
  
  <pre><code>&lt;mvc:interceptors&gt;
   &lt;mvc:interceptor&gt;
     &lt;mvc:mapping path="/**" /&gt;
     &lt;bean class="cz.coffeeexperts.feedback.server.web.interceptors.RestAuthorizationInterceptor" /&gt;
   &lt;/mvc:interceptor&gt;
  &lt;/mvc:interceptors&gt;  
  </code></pre>
  
  <p>So the question is, what is wrong with my path?</p>