原因:
是父子容器的问题
切面代码和连接点,通知都没有问题,问题出在了我的配置信息上面。
我将配置信息如下:
<aop:aspectj-autoproxy proxy-target-class="true"/>
<bean id="caFaceAuthAspect" class="com..aspect.CxxxAuthAspect"/>
将其配置在了spring-context.xml 核心配置文件中,该配置文件会被ContextLoaderListenerclass加在,Spring会创建一个WebApplicationContext上下文,称为父上下文(父容器) ,保存在 ServletContext中,keyWebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE的值。
而spring-mvc.xml是DispatcherServlet,可以同时配置多个,每个 DispatcherServlet有一个自己的上下文对象(WebApplicationContext),称为子上下文(子容器),子上下文可以访问父上下文中的内容,但父上下文不能访问子上下文中的内容。 它也保存在 ServletContext中,key是"org.springframework.web.servlet.FrameworkServlet.CONTEXT"+Servlet名称
当spring加在父容器的时候就会去找切入点,但是这个时候切入的controller是在子容器中的,父容器是无法访问子容器,所以就拦截不到。可以将上述的配置文件放到spring-mvc.xml中。