首页>代码>基于SpringBoot+Vue滑雪场管理系统的设计与实现>/源代码/huaxuechang/src/main/java/com/config/InterceptorConfig.java
package com.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import com.interceptor.AuthorizationInterceptor;

@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport{
	
	@Bean
    public AuthorizationInterceptor getAuthorizationInterceptor() {
        return new AuthorizationInterceptor();
    }
	
	@Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getAuthorizationInterceptor()).addPathPatterns("/**").excludePathPatterns("/static/**");
        super.addInterceptors(registry);
	}
	
	/**
	 * springboot 2.0配置WebMvcConfigurationSupport之后,会导致默认配置被覆盖,要访问静态资源需要重写addResourceHandlers方法
	 */
	@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/**")
        .addResourceLocations("classpath:/resources/")
        .addResourceLocations("classpath:/static/")
        .addResourceLocations("classpath:/admin/")
        .addResourceLocations("classpath:/img/")
        .addResourceLocations("classpath:/front/")
        .addResourceLocations("classpath:/public/");
		super.addResourceHandlers(registry);
    }
}
最近下载更多
lilong007  LV23 2024年9月3日
cyd yyds  LV2 2024年8月7日
sweetlove  LV20 2024年7月30日
ynapen  LV1 2024年6月27日
zeng1206  LV7 2024年6月18日
叉烧君  LV3 2024年5月21日
AlanLi  LV19 2024年5月12日
不顾asdf  LV7 2024年4月9日
123456nty  LV37 2024年4月5日
wanglinddad  LV55 2024年4月5日
最近浏览更多
interface  LV22 4月27日
niuwa666 4月3日
暂无贡献等级
2022102154  LV1 3月27日
blanknb 3月18日
暂无贡献等级
没有啊很开心啊  LV4 3月7日
dadassss  LV5 2024年12月27日
ilovecode521  LV5 2024年12月26日
暂无贡献等级
微信网友_7261917164982272 2024年11月20日
暂无贡献等级
citybird  LV4 2024年11月18日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友