知识点1: proxy-target-class 属性值决定bean是基于jdk的接口方式的还是基于类的代理(CGLIB)被创建。
在ssh整合的项目中如果action继承了实现了别的接口的类,比如ActionSupport,ActionSupport实现了Action等接口,
在用aop拦截action的时候如果不指定proxy-target-class="true"的话,Spring会默认按照jdk默认接口的方式去代理对象,
由于Action没有父类实现的接口的方法,就会报java.lang.NoSuchMethodException: $Proxy97.test()
解决方式: <aop:aspectj-autoproxy proxy-target-class="true"/>

本文探讨了在SSH(Struts+Spring+Hibernate)整合项目中使用AOP(面向切面编程)时遇到的问题,特别是当Action类继承了实现特定接口的基类时,如何通过设置proxy-target-class属性为true来避免NoSuchMethodException异常。

480

被折叠的 条评论
为什么被折叠?



