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";
}
是否可以通过显示方法读取显示方法中的注释SampleAnnotation的value参数?
Is there a way to read the value parameter of the annotation SampleAnnotation in the display method if my aspect?
感谢您的帮助, 埃里克
Thanks for your help, erik
推荐答案
将建议签名更改为
@Around(value="@annotation(sampleAnnotation)")
public Object display(ProceedingJoinPoint joinPoint, SampleAnnotation sampleAnnotation ) throws Throwable {
// ...
}
,您将可以访问批注中的值.
and you will have access to the value in the annotation.
See docs for more info.
这篇关于Spring AOP:获取切入点注释的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文