美文网首页
静态资源配置的问题

静态资源配置的问题

作者: 咪雅先森 | 来源:发表于2019-01-10 15:05 被阅读0次

    spring boot 的项目是将静态资源打包到.jar 的文件包中, 项目中有碰到需要使用外部静态资源的
    情况,使用外部资源的一直老出问题,查了google 后发现是指定的方式不对。

    静态资源配置

    resource/static 进行映射,springboot 默认优先级:

    /META-INF/resources/
    /resources/
    /static/
    /public/
    

    spring 属性合配 resources 配置
    1.本项目包含路径:

    spring:
    mvc:
       static-path-pattern: /late
    resources:
      static-locations: classpath:/templates/dist/
    

    这两天遇到的坑

    2.指定项目外的磁盘路径
    如果要映射本地磁盘路径,可以使用,注意必须得有 file:, 注意必须得有file:,注意必须得有
    file: 否则 404, 重要事情说三遍。

    spring:
    mvc:
       static-path-pattern: /late
    resources:
    

    相关文章

      网友评论

          本文标题:静态资源配置的问题

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