Java 如果围绕操作类创建代理建议,则SpringWeb应用程序上下文不会返回Struts2操作方法

Java 如果围绕操作类创建代理建议,则SpringWeb应用程序上下文不会返回Struts2操作方法,java,spring,struts2,aop,interceptor,Java,Spring,Struts2,Aop,Interceptor,我试图使用SpringAOP截取Struts2的action类的方法,但没有成功。从SpringWeb应用程序上下文返回的bean不仅仅具有操作类的方法(使用反射进行检查)。但是它只有ActionSupport类(StrutsAPI)的方法,我们的操作类就是从这些方法扩展而来的 我可以在日志中看到: 16:55:20,328 DEBUG [org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator]

我试图使用SpringAOP截取Struts2的action类的方法,但没有成功。从SpringWeb应用程序上下文返回的bean不仅仅具有操作类的方法(使用反射进行检查)。但是它只有ActionSupport类(StrutsAPI)的方法,我们的操作类就是从这些方法扩展而来的

我可以在日志中看到:

16:55:20,328 DEBUG [org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator] (http-01h3463916-172.20.211.235-8543-5) Creating implicit proxy for bean 'deviceAction' with 0 common interceptors and 2 specific interceptors

16:55:20,328 DEBUG [org.springframework.aop.framework.JdkDynamicAopProxy] (http-01h3463916-172.20.211.235-8543-5) Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [com.tcs.oss.tims.deviceManagement.action.DeviceAction@70103f6e]

16:55:20,332 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (http-01h3463916-172.20.211.235-8543-5) Finished creating instance of bean 'deviceAction'
返回的ActionBean对象的类型为:class com.sun.proxy.$Proxy36

有趣的是,其他bean(不是Actionbean)即使是由SpringAOP通知的,返回的代理对象也包括bean声明类的所有方法


非常感谢您的帮助……

我终于成功了。这是由于Spring的代理机制基于接口的代理(JDK代理)或基于类的代理(基于CGLib的代理)。因为,我的action类是从ActionSupport类扩展而来的,而ActionSupport类又有一个接口实现。。为Action类创建了一个JDK代理——它没有任何特定于Action类的方法(非继承)

在AOP配置中添加proxy target class=“true”属性使Spring生成基于CGLib(需要在类路径中添加CGLib)的代理。。它现在具有Action类的非继承方法

无论如何,谢谢……;)