首页>代码>基于SpringBoot+Vue实现的酒店管理系统>/源代码/springbootb1g8z/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);
    }
}
最近下载更多
atheking  LV18 9月4日
yangchengshuai  LV16 9月3日
after_666  LV3 8月20日
ES大兵  LV11 8月12日
duizhang  LV6 7月25日
elysion  LV6 7月15日
XJH939  LV3 6月3日
haitianjiaoyu0  LV8 5月27日
liuqingfang  LV4 5月21日
最近浏览更多
khmumuno 10月24日
暂无贡献等级
yigu123  LV6 10月22日
ymsyms  LV2 10月21日
chokkint  LV12 10月17日
sdfb21 10月13日
暂无贡献等级
perfect  LV17 10月11日
wyx065747  LV67 10月1日
310834626  LV3 9月29日
1231578  LV9 9月28日
f22m1a2b2  LV17 9月27日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友