异常如下:报NoSuchMethodException异常,或者只能拦截service和dao 的实现类,
NoSuchMethodException:$Proxy6.login()
原因:
spring3 默认使用JDK动态代理来实现AOP,如果struts2使用的动态方法调用,则spring3只能代理实现了接口的类,而不能代理action控制器,
解决方法:
给spring3 AOP修改配置参数:
<aop:aspectj-autoproxy proxy-target-class="true"/>
<bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator">
<property name="proxyTargetClass" value="true"/>
</bean>
这样spring3会采用CGLIB库来给没有接口的类生成代理,进而实现AOP,