首页>代码>基于SpringBoot+Vue实现的家具电子商城系统>/源代码/springbooth4q2o/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); } }
最近浏览更多
shaohuaqingfu LV3
昨天
elysion LV6
昨天
kfq33122 LV4
昨天
MrReady LV14
前天
微信网友_7041036943331328 LV3
前天
微信网友_6927932988952576 LV12
11月4日
xiejingxun LV2
11月4日
lisansiwu LV1
11月4日
xiaozhi丶 LV15
11月4日
locklock LV2
11月4日