首页>代码>基于SpringBoot+Vue医院管理系统的设计与实现>/源代码/服务端代码/springboot3v5bn/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);
    }
}
最近下载更多
AlanLi  LV19 5月12日
Myangyyyy  LV10 5月10日
wanglinddad  LV55 5月8日
JulyMagnolia  LV4 4月29日
xiaozhi丶  LV14 4月22日
123456nty  LV37 4月18日
JQY123  LV3 4月16日
周青松5  LV3 4月16日
最代码官方  LV167 4月14日
最近浏览更多
sunlzh888888  LV28 5月14日
pxc1994  LV9 5月14日
痕迹7456  LV2 5月14日
Rrithtail  LV1 5月14日
AlanLi  LV19 5月12日
oyjq0000  LV1 5月11日
1941549176  LV4 5月11日
新工艺  LV8 5月10日
ma406805131  LV12 5月10日
可是不知道么  LV23 5月10日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友