@Configuration public class WebMvcConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { String os = System.getProperty("os.name"); if (os.toLowerCase().startsWith("win")) { //如果是Windows系统 registry.addResourceHandler("/imgs/**") // /apple/**表示在磁盘apple目录下的所有资源会被解析为以下的路径 .addResourceLocations("file:D:/hdkupload/upload/imgs/"); //媒体资源 } else { //linux 和mac registry.addResourceHandler("/smallapple/**") .addResourceLocations("file:/resources/smallapple/"); //媒体资源 } } }
springBoot配置资源路径
最新推荐文章于 2024-06-25 15:38:51 发布