<aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>
<bean id="profiler" class="cn.com.xyz.action.SimpleProfiler" />
<aop:config>
<aop:aspect ref="profiler">
<aop:pointcut id="test" expression="(execution(* cn.com.xyz.action.*Action.*()))" />
<aop:around pointcut-ref="test" method="profile" />
</aop:aspect>
</aop:config>
通过一下这篇文章:http://xuxingyin.iteye.com/blog/600091
struts.xml文件: <action name="login" class="memberAction" method="login"> spring的applicationcontext.xml配置文件: //action <bean id="memberAction" <!-- 自动代理对象 --> 当struts2的action没有配置动态方法调用的时候,运行正常。当使用动态方法调用的时候,运行时报 类似: NoSuchMethodException:$Proxy6.login() 的错误,解决办法是使用CGLib实现aop,加上 <property name="proxyTargetClass" value="true"/> 如果使用 aop:方式的话,加上<aop:aspectj-autoproxy proxy-target-class="true"/> |
应该注意的是expression="(execution(* cn.com.xyz.action.*Action.*()))" 路径一定要配置正确要不出莫名其妙的问题,这里总结下留下作为以后参考!