spring AOP的几种通知方式

1.前置通知

方法调用前通知

<aop:before method="beginTransaction" pointcut-ref="perform"/>

2.后置通知

方法调用后正常返回的时候通知,可以获取返回值,发生异常的时候不会执行

<aop:after-returning method="commit" pointcut-ref="perform" returning="val"/>

3.最终通知

无论程序是否发生异常都会执行的

<aop:after method="finallyMethod" pointcut-ref="perform"/>

4.异常通知

发生异常的执行

<aop:after-throwing method="throwingMethod" throwing="ex" pointcut-ref="perform"/>

5.环绕通知

方法执行的时候执行

<aop:around method="aroundMethod" pointcut-ref="perform"/>

猜你喜欢

转载自blog.csdn.net/baidu_23880309/article/details/79852798