前面已经介绍了,AOP的使用和XML配置
Spring面向切面编程(AOP)三之AOP的使用及XML配置
在配置AOP的切面的时候,除了<aop:before>
这种前置通知以外,还有以下几种通知类型
后置通知<aop:after-returning>
、环绕通知<aop:around>
、异常通知<aop:after-throwing>
、最终通知<aop:after>
<aop:aspect ref="myaspect">
<!--前置通知-->
<aop:before method="check" pointcut-ref="cheaksave"/>
<!--后置通知,还可以拿到切入点的返回值给通知-->
<aop:after-returning method="log" pointcut-ref="logupdate" returning="obj"/>
<!--环绕通知,可以在切入点之前或者之后加上通知,还可以控制切入点的是否执行-->
<aop:around method="around" pointcut-ref="arounddelete"/>
<!--异常通知,有异常发生的时候,才会添加上这个通知,还可以拿到异常信息-->
<aop:after-throwing method="throwsMessage" pointcut-ref="throwsquery" throwing="ex"/>
<!--最终通知,不管有没有异常,都会执行的通知-->
<aop:after method="after" pointcut-ref="afterquery"/>
</aop:aspect>