考虑我已经定义了以下方面:
@Aspect
public class SampleAspect {
@Around(value="@annotation(sample.SampleAnnotation)")
public Object display(ProceedingJoinPoint joinPoint) throws Throwable {
// ...
}
}
和注释
public @interface SampleAnnotation {
String value() default "defaultValue";
}
如果我的aspect有没有办法读取显示方法中注解SampleAnnotation的value参数?
感谢您的帮助, 埃里克
最佳答案
将建议签名更改为
@Around(value="@annotation(sampleAnnotation)")
public Object display(ProceedingJoinPoint joinPoint, SampleAnnotation sampleAnnotation ) throws Throwable {
// ...
}
您将可以访问注释中的值。
见 docs了解更多信息。
关于 Spring AOP : Getting parameters of the pointcut annotation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5282242/