@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
//必须强转为HandlerMethod
HandlerMethod handlerMethod = (HandlerMethod) handler;
//获取类上的注解
IgnoreAuth clazzAnnotation = handlerMethod.getBeanType().getAnnotation(IgnoreAuth.class);
//判断类上是否有打该注解
boolean clazzAnnotationPresent = handlerMethod.getBeanType().isAnnotationPresent(IgnoreAuth.class);
//获取方法上的注解 方式1
IgnoreAuth methodAnnotation_1 = handlerMethod.getMethodAnnotation(IgnoreAuth.class);
//获取方法上的注解 方式2
IgnoreAuth methodAnnotation_2 = handlerMethod.getMethod().getAnnotation(IgnoreAuth.class);
//判断方法上是否有打该注解
boolean methodsAnnotationPresent = handlerMethod.getMethod().isAnnotationPresent(IgnoreAuth.class);
}
版权声明:本文为yuru974882032原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。