首页>代码>基于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);
    }
}
最近下载更多
不顾asdf  LV7 4月9日
123456nty  LV37 4月5日
wanglinddad  LV55 4月5日
305865088  LV7 4月4日
dapeng0011  LV13 3月28日
Rommel  LV27 3月27日
最代码官方  LV167 3月24日
最近浏览更多
暮春念五 前天
暂无贡献等级
IT小牛  LV3 4月29日
zolscy  LV12 4月24日
19960721  LV9 4月22日
1230123  LV1 4月21日
akittyboy  LV9 4月16日
java小书童  LV17 4月16日
周青松5  LV2 4月16日
zhangtian1997  LV10 4月15日
80730176  LV7 4月13日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友