Spring面向切面编程(AOP)四之AOP的XML配置通知类型

前面已经介绍了,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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值