1. 程式人生 > >springMVC攔截器不起作用

springMVC攔截器不起作用

今天專案中需要加springMVC攔截器,但是加上了不起作用,我仔細查看了一下,原來是因為在springmvc.xml檔案中配置的這個<mvc:annotation-driven/>   配置檔案導致的攔截器失效,  我把這個註釋掉,改成原始的包掃描的方式獲取controller,就起作用了.改成如下這種

<context:component-scan base-package="com.baidu.controller" use-default-filters="false">
      <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>