29 lines
1018 B
Java
29 lines
1018 B
Java
package com.mini.mybigscreen.Config;
|
|
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
@Configuration
|
|
public class WebConfig implements WebMvcConfigurer {
|
|
|
|
@Resource
|
|
private LoginInterceptor loginInterceptor;
|
|
|
|
|
|
@Override
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
// 注册登录拦截器,拦截所有请求,排除登录接口
|
|
registry.addInterceptor(loginInterceptor)
|
|
.addPathPatterns("/**") // 拦截所有路径
|
|
.excludePathPatterns(
|
|
"/",
|
|
"/index.html",
|
|
"/userLogin"
|
|
)
|
|
.excludePathPatterns("/static/**")
|
|
.excludePathPatterns("/assets/**")
|
|
; // 排除静态资源(前端打包后的文件)
|
|
}
|
|
} |