添加MyPicConfig类,并重写相关方法,为项目的图片文件夹添加如下映射:
@Configuration
public class MyPicConfig implements WebMvcConfigurer {
//添加虚拟路径映射
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/images/**").addResourceLocations("file:E:\blog-2020\src\main\resources\static\images\");
}
}