參考:http://zhanghua.1199.blog.163.com/blog/static/46449807201111139501298/
做項目的時候,由於要用到在Struts2的Action類中利用Spring的AOP來實現記錄操作日志,
在Action里面的方法中加上自定義annotation來實現記錄操作功能,
運行的時候頁面提示NoSuchMethodException when Aspec,
網上說是Action繼承了ActionSupport導致的,
后來在一個英文網站上找到了解決的方法,
只要在Spring的配置文件applicationContext中的<aop:aspectj-autoproxy/>改為<aop:aspectj-autoproxy proxy-target-class="true"/>就可以了。
第一步:
在struts2的配置文件里加上以下一句:
//讓struts2始終先考慮spring的自動裝箱
<constant name="struts.objectFactory.spring.autoWire.alwaysRespect" value="true" />
第二步:
在配置AOP時,加上
<aop:aspectj-autoproxy proxy-target-class="true"/>//關鍵是這句話,配置上就行了,
英文原文:http://forum.springsource.org/showthread.php?t=51758