1.这边配置的是图片路径在项目外的文件夹
2.linux服务器版本配置静态资源
(重点是用File.separator代替“/”)
@Configuration
public class UploadConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//映射图片保存地址
registry.addResourceHandler("/content/upload/**")
.addResourceLocations("file:" + File.separator + "opt" + File.separator + "wxmanage" + File.separator + "upload" + File.separator);
}
}
网友评论