首页>代码>Spring Boot+Maven+Spring Data JPA+Layui实现销售培训考评系统>/topsec_hr/src/main/java/cn/temptation/config/DefineAdapter.java
package cn.temptation.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class DefineAdapter implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    // 登录拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 排除不被拦截的资源
        List<String> excludePaths = new ArrayList<>();
        // layui的静态文件
        excludePaths.add("/layui/**");

        // 静态页面
        excludePaths.add("/**/*.html");
        excludePaths.add("/css/*.css");
        excludePaths.add("/images/*.png");

        // 登录:以 / 或 /login 均可访问
        excludePaths.add("/");
        excludePaths.add("/login");
//        excludePaths.add("/error");

        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns(excludePaths);
    }
}
最近下载更多
Seaskye  LV14 2023年11月4日
dzlwindy  LV8 2023年6月29日
张真狗  LV9 2023年6月10日
jhh123  LV4 2023年5月28日
zhunishimian  LV6 2023年5月22日
qq2901732871  LV9 2023年5月5日
java小书童  LV17 2023年3月29日
17861270371  LV1 2023年2月22日
jxtzuidaima  LV8 2023年1月31日
rain112  LV30 2022年12月30日
最近浏览更多
玖零定制问题修复  LV34 4月4日
阿凡达  LV9 1月10日
Dominick  LV14 2023年12月27日
admin_z  LV22 2023年12月26日
hhh12345  LV7 2023年12月23日
jiyun2021  LV9 2023年12月2日
murphy  LV6 2023年11月20日
fff2003  LV6 2023年11月17日
Seaskye  LV14 2023年11月4日
3334004690  LV3 2023年11月1日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友