首页>代码>基于SpringBoot+Vue实现的企业资产管理系统>/源代码/springboot4j9k2/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:/front/")
        .addResourceLocations("classpath:/public/");
		super.addResourceHandlers(registry);
    }
}
最近下载更多
pairw888  LV1 2024年11月25日
15953970869  LV6 2024年11月10日
weekadmin  LV1 2024年10月21日
微信网友_7005760998215680  LV6 2024年9月19日
xinxin23383  LV7 2024年9月13日
微信网友_7044194812350464  LV8 2024年9月13日
放开那女孩  LV15 2024年9月6日
lilong007  LV23 2024年8月28日
202106  LV6 2024年8月27日
mlml123  LV6 2024年8月20日
最近浏览更多
yidongdematong  LV2 6月12日
koteilbs  LV6 5月16日
15009291076 5月13日
暂无贡献等级
muliuhanyun  LV4 5月10日
luhong  LV4 5月6日
拜托你仔细听  LV3 4月19日
youwuzuichen  LV11 4月3日
小月月呀  LV19 3月29日
fantesy  LV17 3月24日
billy-zuidaima  LV1 3月24日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友