SpringBoot 常用配置 静态资源访问配置/内置tomcat虚拟文件映射路径
作者:互联网
Springboot 再模板引擎中引入Js等文件,出现服务器拒绝访问的错误,需要配置过滤器
静态资源访问配置
@Configuration @EnableWebMvc public class StaticResourceConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); } }
内置tomcat虚拟文件映射路径
@Configuration public class WebMvcConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/image/**").addResourceLocations("file:C:/image/"); } }
标签:ResourceHandlerRegistry,SpringBoot,tomcat,image,配置,static,registry,public,addRes 来源: https://www.cnblogs.com/ChromeT/p/11372927.html