标题
###1、注解
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.METHOD,ElementType.TYPE})
@Documented
public @interface Unlogin {
}
###2、
@Component
public class SecurityInterceptor implements HandlerInterceptor {
private final static Logger logger = LoggerFactory.getLogger(LogFilter.class);
在这个类里添加逻辑
Method handlerMethod = ((HandlerMethod) handler).getMethod();
Unlogin annotation = handlerMethod.getAnnotation(Unlogin.class);
if (null != annotation){
return true;
}
3、将这个注解放在任何你想要的方法或类上
@PostMapping("/xxx")
@Unlogin
public Response xxx(@ModelAttributeReq req) {
// }