1.application.yml
#上传图片地址
upload:
abouts: E://abouts/
fellbackVideo: E://feelback/video/
feelbackImg: E://feelback/img/
cnnsulting: E://consulting/
2.静态资源映射配置
public class WebMvcImgConfig extends WebMvcConfigurerAdapter{
#1.addResourceHandler:需要访问的路径
#2.addResourceLocations:映射的资源路径
@Override
publice void addResourceHandlers(ResourceHandlerRegistry registry){
registry.addResourceHandler("/abouts/**").addResourceLocations("file:E://abouts/");
registry.addResourceHandler("/feelBack/img/**").addResourceLocations("file:E://feelback/img/");
registry.addResourceHandler("/feelBack/video/**").addResourceLocations("file:E://feelback/video/");
registry.addResourceHandler("/consulting/**").addResourceLocations("file:E://consulting/");
super.addResourceHandlers(registry);
}
}
上传的地址以 ip+端口+具体访问资源
例:
http://10.182.1.126/operation/feelBack/img/file.png
如果访问路径中有:server-servlet-context-path,需要自己配置一下。
这里的:operation 就是路径当中的server-servlet-context-path。