加上advice后一个方法多执行了两次,怎么回事
用ssh2框架
spring配置:
<bean id="loginAdvice" class="com.project.security.LoginAdvice" />
<aop:config>
<aop:advisor pointcut="execution(public * com.project.web.*.*(..))" advice-ref="loginAdvice" />
</aop:config>
LoginAdvice代码:
public class LoginAdvice implements MethodInterceptor{
public Object invoke(MethodInvocation args) throws Throwable {
if (args.proceed() != null)
return args.proceed();
}
}
Action代码:
public String execute() throws Exception {
System.out.println("run execute()");
}
public String list() {
System.out.println("run list()");
}
这样页面访问Action的list方法时,execute和list都被执行了3次!!,去掉spring中的那些配置后又正常的执行1次了!
这是aop环绕侦听吗,我想设置方法执行前侦听,是不是就可以只执行1次目标方法了?