【问题标题】:Spring Boot unable to find the images in /resources/static/images folderSpring Boot 无法在 /resources/static/images 文件夹中找到图像
【发布时间】:2019-05-18 13:22:45
【问题描述】:

我正在尝试像这样在 html 中加载图像

<body>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-4"><img class="img-fluid" src="../static/images/zep.png" /></div>
        </div>
        <div class="row justify-content-center">
            <div class="col-md-12 text-center"><h1>Coming Soon.</h1></div>
            <!-- <div class="col-md-12 text-center"><p>Subscribe to our newsletter and stay tuned</p></div> -->
        </div>
        <!-- <div class="col-md-12 text-center"><button class="btn btn-custom">Subscribe</button></div> -->
    </div>
</body>

这是我的文件夹结构

所以当我运行它时,我得到了

Failed to load resource: the server responded with a status of zep.png:1 404 ()

我做错了什么?任何帮助,将不胜感激。谢谢

【问题讨论】:

  • 仍未加载

标签: java html spring spring-boot


【解决方案1】:

您不应在img 标签的src 中包含static。放置在src/main/resources/static 中的资源将从应用程序的根目录提供。这意味着src/main/resources/static/images/zep.png 将从/images/zep.png 提供服务。

【讨论】:

    猜你喜欢
    • 2017-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-01
    • 1970-01-01
    • 2022-01-26
    • 2020-06-03
    • 2017-09-12
    相关资源
    最近更新 更多