拦截器Interceptor
拦截器的使用:
首先注册一个拦截器
①先定义一个类LoginCheckInterceptor,继承接口HeaderInterceptor
②实现默认方法
preHandle() 目标资源实现之前执行,返回true代表放行,false代表拦截
postHandle() 目标资源实现之后执行
afterCompletion() 目标资源实现完成后执行
此次配置拦截器
①定义一个类Webconfig继承接口WebmvcConfigurer,添加注解@Configuretion
②实现方法interceptors
public void addInterceptors(InterceptorRegistry registry)
拦截路径: