spring aop @after和@before之类的注解,怎么指定多个切点

J2EE 码拜 7年前 (2017-05-03) 5536次浏览
有如下两个切点:
@Pointcut(“execution(public * com.wyh.data.controller.DepartmentController.*(..))”)
public void department(){}
@Pointcut(“execution(public * com.wyh.data.controller.UserController.*(..))”)
public void user(){}
@Before(“department()”)//怎么在这里指定多个切点,逗号不可以
public void before(JoinPoint joinPoint){do something}
除了写重复代码,没有更简便的方法了吗
解决方案

40

好像可以使用&&、||、!。例如@Before(“department() || user()”)…你试试管不管用

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明spring aop @after和@before之类的注解,怎么指定多个切点
喜欢 (0)
[1034331897@qq.com]
分享 (0)