import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/**
* @Description: 静态资源配置 拦截器添加
* @author cf
*/
@Configuration
public class WebMvcConfigurerAdapter extends WebMvcConfigurationSupport {
/**
* 配置静态资源
*/
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
registry.addResourceHandler("/templates/**").addResourceLocations("classpath:/templates/");
/*放行swagger*/
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
super.addResourceHandlers(registry);
}
}
版权声明:本文为qq_32784303原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。