spring:
session:
store-type: HASH_MAP
cache:
type: None
mvc:
static-path-pattern: /image/**
resources:
static-locations: file:/opt/gray/imagesspring boot在本地测试好的在服务器上配置路径访问图片就404了
1 回答
慕村4705583
TA贡献40条经验 获得超14个赞
可以考虑在代码中配置。
比如:
@Configuration public class WebMvcConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); registry.addResourceHandler("/files/**").addResourceLocations("file:///home/community_cloud_admin/upload/images/"); registry.addResourceHandler("/app/**").addResourceLocations("file:///home/community_cloud_admin/upload/package/"); // registry.addResourceHandler("/app/**").addResourceLocations("file:///D:/community_cloud_admin/upload/package/"); super.addResourceHandlers(registry); }
其中 addResourceHandler 是打开路径 addResourceLocations则是存放路径
添加回答
举报
0/150
提交
取消