Springboot添加静态资源映射addResourceHandlers,可实现url访问
@Configuration
//public class WebMvcConfiger extends WebMvcConfigurerAdapter { public class WebMvcConfiger implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/picture/**").addResourceLocations("file:D:/picture/"); } }
registry.addResourceHandler("/picture/**") //表示文件路径,这里的意思是picture包下的所有文件,所有/picture/开头的请求 都会去后面配置的路径下查找资源 .addResourceLocations("file:D:/picture/"); //表示要开放的资源
做人如果没有梦想,那根咸鱼有什么区别!!!