title: Spring MVC: Why does this <mvc:interceptors> declaration work, but not the traditional XML?
body: <p>I'm trying to add some <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/web/servlet/handler/HandlerInterceptorAdapter.html" rel="nofollow">HandlerInterceptorAdaptor</a>s to ALL of my Controllers/Actions in Spring MVC.  I'm adding these to my servlet XML file.  </p>
  
  <p>What I don't understand, is why the <code>&lt;mvc:interceptors&gt;</code> block I have below is working, but not the traditional bean declaration with <code>DefaultAnnotationHandlerMapping</code>.</p>
  
  <p>Here is the XML that is working:</p>
  
  <pre><code>&lt;mvc:interceptors&gt;
      &lt;bean name="interceptor1" class="com.foo.bar" /&gt;
      &lt;bean name="interceptor2" class="com.foo.bar2" /&gt;
  &lt;/mvc:interceptors&gt;
  </code></pre>
  
  <p><br /><br />
  Here is the XML that I can't get to work:</p>
  
  <pre><code>&lt;bean name="interceptor1" class="com.foo.bar" /&gt;
  &lt;bean name="interceptor2" class="com.foo.bar2" /&gt;
  &lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt;
      &lt;property name="order" value="0" /&gt;
      &lt;property name="interceptors"&gt;
          &lt;list&gt;
              &lt;ref bean="interceptor1"/&gt;
              &lt;ref bean="interceptor2"/&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I thought that Spring would automatically pick up my bean of type <code>DefaultAnnotationHandlerMapping</code>, but that doesn't seem to be the case.  </p>
  
  <p>Note that I'm annotating all of my Controller classes with <code>@Controller</code> and the methods within the Controller with <code>@RequestMapping</code>.</p>
  
  <p>Any thoughts?</p>