美文网首页
springboot中路径地址

springboot中路径地址

作者: 墨色尘埃 | 来源:发表于2019-05-17 15:48 被阅读0次

SpringBoot(六)-- 静态资源处理

静态资源配置文件
前端上传图片保存到本地静态资源路径下,再通过url获取
springboot静态资源文件映射
springboot访问静态资源

① application.yml
② application-dev.yml
③ application-prod.yml
三个配置文件中都有static-locations,如果此时application.yml中配置的是dev的开发环境,那么application-dev.yml里的static-locations会覆盖application.yml里的 static-locations

① application.yml 配置文件

spring:
  resource: 
    static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
  profiles:
    active: dev

② application-dev.yml 配置文件

spring:
  resources:
      static-locations: file:/F:/Files/jscmp

现在F:\Files\jscmp\upload\2019-05-31路径下有31号一张图片,可以通过url访问该图片。此时②路径覆盖① 路径,因为配置文件中路径是:F:/Files/jscmp,所以url是 http://127.0.0.1:10002/upload/2019-05-31/1134263540202262529

image.png

相关文章

网友评论

      本文标题:springboot中路径地址

      本文链接:https://www.haomeiwen.com/subject/jyfoaqtx.html