首页>代码>基于SpringBoot+Vue实现的社区物业管理系统>/源代码/shequwuyeguanli/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);
    }
}
最近下载更多
molu123456 5月21日
暂无贡献等级
102404426  LV8 2月24日
zolscy  LV24 2024年11月24日
citybird  LV4 2024年11月17日
罗清晨  LV13 2024年11月4日
七梦辞  LV2 2024年10月14日
sodkj123  LV16 2024年10月8日
komejikoishi  LV2 2024年9月22日
放开那女孩  LV15 2024年9月6日
lilong007  LV23 2024年8月28日
最近浏览更多
短巷拥猫  LV12 6月18日
yifeng868  LV9 6月10日
weilei  LV1 6月5日
lkke23047  LV1 5月26日
molu123456 5月21日
暂无贡献等级
林品如  LV1 5月17日
5418888  LV3 5月13日
muliuhan 5月10日
暂无贡献等级
muliuhanyun  LV4 5月10日
萌萌哒的泰迪熊  LV4 5月8日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友