1、使用注解@Configuration配置拦截器
2、继承WebMvcConfigurerAdapter
3、重写addInterceptors添加需要的拦截地址
首先我们自定义Interceptor(继承HandlerInterceptor)对于里面的类做相应的了解
我们可以针对不同业务功能去选择不同的Handle方法,我针对这个Interceptor写了一个Controller层,并准备了两套。
接下来我们新建一个继承WebMvcConfigurerAdapter的类,重写它的addInterceptors,在注册中添加想要拦截的url等。
且是顺序拦截的,也支持一个Interceptor,拦截多个url操作。