我試圖攔截Struts2 Action類的方法來使用Spring AOP打印方法開始和方法結束指示語句。使用Spring AOP攔截Struts 2操作方法
事實是,我的Struts2 action實例也是Spring bean(根據url:http://www.mkyong.com/struts2/struts-2-spring-integration-example/完成Struts2和Spring集成)。 AOP的配置是如下:
<bean id="testAdviceBean" class="com.tcs.oss.plugins.SimpleAdvice">
</bean>
<aop:config>
<aop:aspect ref="testAdviceBean" order="200">
<aop:pointcut id="testPoint2"
expression="execution(java.lang.String com.test..DeviceAction.*(..))"
/>
<aop:around pointcut-ref="testPoint2" method="loggingAdvice" />
</aop:aspect>
</aop:config>
通知方法loggingAdvice,我試圖打印使用ProceedingJoinPoint API.The諮詢方法根本不叫方法START和方法END語句...代替它結束了與錯誤通過支柱默認攔截器鏈會後下方...
但我發現了以下錯誤跟蹤:
09:26:49093 TRACE [org.springframework .B eans.factory.support.DefaultListableBeanFactory] (http-01h3463916-172.20.211.235-8543-5)忽略bean'org的構造函數[public org.apache.struts2.dispatcher.ServletDispatcherResult(java.lang.String)] 。 apache.struts2.dispatcher.ServletDispatcherResult': org.springframework.beans.factory.UnsatisfiedDependencyException: 與名 錯誤創建豆‘org.apache.struts2.dispatcher.ServletDispatcherResult’:不滿意 依賴通過構造函數的參數表示索引爲0類型 [java.lang.String]::沒有找到依賴關係的[java.lang.String]類型的匹配bean :預計至少有1個bean,其資格爲 autowire candidate for這種依賴性。依賴註釋:{}; 嵌套的異常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:無類型[java.lang.String中]的 匹配豆找到依賴性: 預期至少1豆,其有資格作爲自動裝配候選 這種依賴性。依賴註解:{}
09:26:49095 TRACE [org.springframework.beans.factory.support.DefaultListableBeanFactory] (HTTP-01h3463916-172.20.211.235-8543-5)不自動裝配屬性 'urlHelper'按名稱豆 'org.apache.struts2.dispatcher.ServletDispatcherResult' 的:無 匹配豆發現
09:26:49100 DEBUG [org.apache.struts2.dispatcher.ServletDispatcherResult] (HTTP-01h3463916- 172.20.211.235-8543-5)轉發至地址 /General/error.jsp
如果我只是刪除上面的AOP配置,它只是工作正常。我做錯了什麼?
我覺得這是HTTP的副本://計算器。 COM /問題/ 20861063/AOP-的MethodInterceptor,休息,Struts2的行動頁 – adam