首页>代码>基于SpringBoot+Vue实现的家政服务平台>/源代码/springbootc90g5/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);
    }
}
最近下载更多
pangzhihui  LV14 2024年11月13日
Brave  LV5 2024年10月17日
微信网友_7044194812350464  LV8 2024年9月13日
lilong007  LV23 2024年8月28日
mlml123  LV6 2024年8月20日
cyd yyds  LV2 2024年8月7日
zxc123zdq  LV15 2024年7月3日
xunxia  LV7 2024年6月27日
TY0165  LV20 2024年6月15日
sweetlove  LV20 2024年6月2日
最近浏览更多
haitianjiaoyu0  LV8 5月27日
不知道的ME  LV1 5月26日
lkke23047  LV1 5月26日
yykyyds 5月22日
暂无贡献等级
5418888  LV3 5月13日
wang00798 5月9日
暂无贡献等级
luhong  LV4 5月6日
hubugai1  LV11 4月27日
interface  LV22 4月27日
15838634741  LV18 4月7日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友