本人有一个Action,然后调用它的forMain()方法的之前,希望用AOP给个小通知。
但是很奇怪,启动服务之后,Spring读取也成功了,但就是当webwork调用Action时就是不理睬我配置的BeforeAdvice。不知道是我理解错误还是配置错误。请各位高手帮我看看~
Action代码:
public class AdjustTransactionAction extends ActionSupport {
public String forMain() throws Exception {
clearConditions();
return SUCCESS;
}
}
给Action的接口:
public interface IAdjustingAction {
public String forMain() throws Exception;
}
小通知Advice代码:
public class AdjustingAdvice implements MethodBeforeAdvice {
public void before(Method method, Object[] args, Object target)
throws Throwable {
System.out.println("各位,通知一下!!");}
}
Spring的Bean配置如下:
<!---->
<bean id="adjustTransactionAction" class="net.jite.sdwzjy.adjust.action.AdjustTransactionAction" singleton="true"><!----> <bean id="adjustAdive" class="net.jite.sdwzjy.adjust.advice.AdjustingAdvice"> <bean id="proxyAdive" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <value>net.jite.sdwzjy.adjust.advice.IAdjustingAction</value> </property> <property name="interceptorNames"> <list> <value>adjustAdive</value> </list> </property> <property name="target"> <ref bean="adjustTransactionAction"> </property> </bean>