Spring Aop 表达式匹配

2022-06-29 10:48:32

Spring Aop 可以匹配多个表达式


	/**
	 * 以do开头的方法切点
	 */
	@Pointcut("execution(* com.abc.action.*Controller.do*(..))")
	public void doPointcut(){}
	
	/**
	 * 以doSelect开头的方法切点
	 */
	@Pointcut("execution(* com.abc.action.*Controller.doSelect*(..))")
	public void doSelectPointcut(){}
	
	/**
	 * <p>
	 * 环绕通知方法
	 * 拦截以do开头的方法但不包含doSelect
	 * @param pjp
	 * @return
	 * @throws Throwable
	 * </p>
	 */
	@Around("doPointcut() && ! doSelectPointcut()")
	public Object doWriteLog(ProceedingJoinPoint pjp) throws Throwable {
               //需要处理的事情

        }

在多个表达式之间使用 ||,or表示 或,使用 &&,and表示 与,!表示 非.
  • 作者:静叶01
  • 原文链接:https://blog.csdn.net/airujingye/article/details/50741781
    更新时间:2022-06-29 10:48:32