思路: 在拦截器中获取所将要执行的方法是否含有 自定义注解。若含有则直接放行。
拦截器:
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
WhiteList whiteList = handlerMethod.getMethod().getAnnotation(WhiteList.class);
if (whiteList != null) {
return true;
}
}
注解
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface WhiteList {
String test() default "test";
}