使用spring的aop对Struts2的Action拦截后出现依赖注入为空问题

两种解决方案:

1、action类继承ActionSupport了后,出现依赖注入为空,要在applicationContext.xml配置中加入:<aop:aspectj-autoproxy proxy-target-class="true"/>

2、要么action类不要继承ActionSupport等类

proxy-target-class="true" 与proxy-target-class="false"的区别:
        proxy-target-class属性值决定是基于接口的还是基于类的代理被创建。如果proxy-target-class 属性值被设置为true,那么基于类的代理将起作用(这时需要cglib库)。如果proxy-target-class属值被设置为false或者这个属性被省略,那么标准的JDK 基于接口的代理

posted @ 2017-03-16 14:37  亦真亦假,何必当真  阅读(352)  评论(0编辑  收藏  举报