[英]Advice is not called from struts 2 action?
下面我在aop.xml中定義了方面
<aspects>
<aspect name="com.customer.MyCustomAspect" />
</aspects>
我的自定義方面在下面定義
@Aspect
public class MyCustomAspect{
@Around("@annotation(requiredPrivilege)")
public Object myAdvice(ProceedingJoinPoint pjp) throws Throwable {
}
現在,當我從struts 2動作調用任何服務方法時,不會調用myAdvice。 每件事都可以與我的舊動作一起正常運行,但不適用於struts 2動作(僅供參考,我正在使用struts2 spring插件jar)。 我不是struts 2的問題嗎?
將struts2-sping-plugin添加到您的項目。
將以下內容添加到struts.xml ...
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
有關更多信息,請參見: http : //struts.apache.org/release/2.0.x/docs/spring-plugin.html
由於spring現在負責對象創建,因此現在可以執行spring AOP魔術(假設spring正確配置)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.