spring mvc拦截器和<mvc:annotation-driven />为什么不共存???

如果使用了<mvc:annotation-driven />, 

  它会自动注册DefaultAnnotationHandlerMapping 与AnnotationMethodHandlerAdapter 这两个bean,

  所以就没有机会再给它注入interceptors属性,就无法指定拦截器。

当然我们可以通过人工配置上面的两个Bean,

  不使用 <mvc:annotation-driven />,就可以 给interceptors属性 注入拦截器了。

posted @ 2020-06-05 09:46  墨尘无雪  阅读(425)  评论(0编辑  收藏  举报