InterceptorUtils工具类:
public class InterceptorUtils { private static Logger logger = getLogger(InterceptorUtils.class); private InterceptorUtils() { } public static <A extends Annotation> A getAnnotation(Object handler, Class<A> annotationClass) { if (!(handler instanceof HandlerMethod)) { return null; } HandlerMethod handlerMethod = (HandlerMethod) handler; A result; if ((result = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), annotationClass)) != null) { logger.trace("found [{}] annotation in method-level:{}", annotationClass.getSimpleName(), handlerMethod.getMethod()); } else { if ((result = AnnotationUtils.findAnnotation(handlerMethod.getBeanType(), annotationClass)) != null) { logger.trace("found [{}] annotation in type-level:{}", annotationClass.getSimpleName(), handlerMethod.getBeanType()); } } return result; } }