1:Pointcut语法
/**
* 切入点:
* 匹配规则。规定什么方法被拦截、需要处理什么方法
* 定义切入点
* @Pointcut("匹配规则")
*
* Aop 切入点表达式简介
* 1. 执行任意公共方法:
* execution(public *(..))
* 2. 执行任意的set方法
* execution(* set*(..))
* 3. 执行com.xxxx.service包下任意类的任意方法
* execution(* com.xxxx.service.*.*(..))
* 4. 执行com.xxxx.service 包 以及子包下任意类的任意方法
* execution(* com.xxxx.service..*.*(..))
*
* 注:表达式中的第一个* 代表的是方法的修饰范围
* 可选值:private、protected、public (* 表示所有范围)
*/
2:通知类型
1:前置通知
2:后置通知
3:异常通知
4:最终通知
5:环绕通知
2.1:注解形式
1: 前置通知 @Before
2:返回通知 @AfterReturning
3:异常通知 @AfterThrowing
4:最终通知 @After
5:环绕通知 @Around
注解类型使用请参考
2.2:配置文件形式
1: 前置通知 <aop:before>
2:返回通知 <aop:after-returning>
3:异常通知 <aop:after-throwing>
4:最终通知 <aop:after>
5:环绕通知 <aop:around>
配置文件类型使用请参考