基于xml的spring-aop 实现方法
1、主要内容:
- 前置通知: 在方法执行之前通知。
- 后置通知: 在方法执行之后通知。
- 异常通知: 在方法出现异常时通知。
- 环绕通知: 全方位控制,可以在其中实现前三种通知。
2、实现接口:
3、aop配置
<aop:config>
//切入点
<aop:pointcut id="pointcut" expression="execution(* cn.com.sise.spring.service.impl.StudentServiceImpl.*(..))"/>
//advisor 连接切入点 和 切面的 线
<aop:advisor advice-ref="logAfterReturningAdvice" pointcut-ref="pointcut"/>
<aop:advisor advice-ref="logBefore" pointcut-ref="pointcut"/>
<aop:advisor advice-ref="logThrow" pointcut-ref="pointcut"/>
<aop:advisor advice-ref="logAround" pointcut-ref="pointcut"/>
</aop:config>
4、bean配置就不再此处赘述。