建议不是从struts 2动作调用的吗?

时间:2013-04-26 12:14:38

标签: java spring struts2 aop struts2-spring-plugin

下面我在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 action调用任何服务方法时,不会调用myAdvice。使用我的遗留操作,每件事都可以正常工作,但不能使用struts 2动作 (仅供参考,我使用的是struts2 spring plugin jar)。我不是struts 2的问题是什么?

1 个答案:

答案 0 :(得分:1)

将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现在负责创建对象,现在它将能够执行它的弹簧AOP魔法(假设弹簧配置正确)。

相关问题