首页>代码>基于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);
    }
}
最近下载更多
luhong  LV4 5月15日
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日
最近浏览更多
caozongan  LV19 7月6日
yifeng868  LV9 6月23日
Dominick  LV14 6月6日
zhaopb  LV8 5月17日
luhong  LV4 5月15日
木子520  LV12 5月14日
interface  LV22 4月27日
niuwa666 4月3日
暂无贡献等级
2022102154  LV1 3月27日
blanknb 3月18日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友