自定义注解简单实现拦截器拦截接口是否有自定义注解,然后进行是否放行(The user-defined annotation simply implements whether the interceptor intercepts the interface with a user-defined annotation, and then whether to release it)-其他
自定义注解简单实现拦截器拦截接口是否有自定义注解,然后进行是否放行(The user-defined annotation simply implements whether the interceptor intercepts the interface with a user-defined annotation, and then whether to release it)
1、自定义注解
@Retention(RetentionPolicy.SOURCE)@Target(ElementType.METHOD)
@Documentedpublic @interface AuthAccess{
}
2、在需要拦截的接口加上该注解
3、然后在拦截器实现上使用反射获取方法是否包含注解进行判断
————————
1. Custom annotation
@Retention(RetentionPolicy.SOURCE)@Target(ElementType.METHOD)
@Documentedpublic @interface AuthAccess{
}
2. Add this annotation to the interface to be intercepted
3. Then, on the interceptor implementation, we use the reflection acquisition method to judge whether the annotation is included