【问题标题】:image not displaying on Web page in Spring boot application图像未显示在 Spring Boot 应用程序的网页上
【发布时间】:2021-07-08 13:45:56
【问题描述】:

我使用 thymeleaf 模板引擎并像这样放置文件。 但图像不显示在网页上。我该如何解决? place files like this result

<span class="Google">
    <a href="">
        <img src="img/google.png">
    </a>
</span>

<span class="kakao">
    <a href="">
        <img src="img/kakao.png">
    </a>
</span>

【问题讨论】:

    标签: spring spring-boot thymeleaf


    【解决方案1】:

    将 / 放在 url 的开头并确保 .png 应该存在于 /resource/static/img/ 目录中

    试试这个

    <span class="kakao">
        <a href="">
            <img src="/img/kakao.png">
        </a>
    </span>
    

    【讨论】:

      【解决方案2】:

      我可能会将图像参考更改为:

      <img th:src="@{/img/google.png}">
      

      它将上下文相关的 url 添加到图像的 uri。

      这里是document

      【讨论】:

        猜你喜欢
        • 2020-11-28
        • 2021-01-05
        • 1970-01-01
        • 2012-07-19
        • 2014-07-31
        • 1970-01-01
        • 1970-01-01
        • 2016-04-03
        • 2013-11-09
        相关资源
        最近更新 更多