定义


@Before

声明一个方法为前置通知

参数


value

String value();
可以为切入点表达式,也可以为使用了@PointCut被声明为切入点的方法。

示例


@Aspect  
@Component
@Slf4j
public class LogAspect {
	@PointCut("@annotation(com.example.annotation.Log)")
	public void logAnnotation() { }
	
	@Before("logAnnotation()")
	public void logBefore(JoinPoint joinPoint) {  
		MethodSignature signature = (MethodSignature) joinPoint.getSignature();  
		Method method = signature.getMethod();
		log.info(“before method:{}”, method.getName());
	}
}
Link to original