【问题标题】:Images not showing up in Thymeleaf image src for S3 URL图像未显示在 S3 URL 的 Thymeleaf 图像 src 中
【发布时间】:2021-06-01 08:26:41
【问题描述】:

我将存储在 S3 中的图像 URL 列表传递给我的 HTML 页面以显示。但是,图像没有显示出来。下面是我的 HTML 文件。 p 标签正确显示网址。

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Display S3 Images</title>
</head>
<body>
<div th:each=" url: ${imageURL}">
    <p th:text="${url}"></p>
    <img src="${url}" width="300" height="300">
</div>
</body>
</html>

P.S 当我对每个 URL 进行硬编码时,图像会显示出来,但显然我不希望这样。任何帮助表示赞赏。

【问题讨论】:

    标签: html amazon-web-services spring-boot amazon-s3 thymeleaf


    【解决方案1】:

    您需要使用th:src 而不是src

    <div th:each="url: ${imageURL}">
        <p th:text="${url}"></p>
        <img th:src="${url}" width="300" height="300">
    </div>
    

    【讨论】:

      【解决方案2】:

      我认为您缺少 CID 表示法。您可以阅读更多相关信息:

      CID NOTATION EXAMPLE

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-09-07
        • 1970-01-01
        • 2019-01-20
        • 1970-01-01
        • 2018-12-03
        • 2011-05-30
        • 1970-01-01
        • 2020-04-10
        相关资源
        最近更新 更多