Spring AOP:获取切入点注解的参数 [英] Spring AOP: Getting parameters of the pointcut annotation
本文介绍了Spring AOP:获取切入点注解的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑我已经定义了以下方面:
Consider I have defined the following aspect:
@Aspect
public class SampleAspect {
@Around(value="@annotation(sample.SampleAnnotation)")
public Object display(ProceedingJoinPoint joinPoint) throws Throwable {
// ...
}
}
和注释
public @interface SampleAnnotation {
String value() default "defaultValue";
}
如果是我的aspect,有没有办法读取display方法中注解SampleAnnotation的value参数?
Is there a way to read the value parameter of the annotation SampleAnnotation in the display method if my aspect?
感谢您的帮助,埃里克
推荐答案
将通知签名更改为
@Around(value="@annotation(sampleAnnotation)")
public Object display(ProceedingJoinPoint joinPoint, SampleAnnotation sampleAnnotation ) throws Throwable {
// ...
}
您将可以访问注释中的值.
and you will have access to the value in the annotation.
见文档 了解更多信息.
这篇关于Spring AOP:获取切入点注解的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文