【发布时间】:2020-04-19 05:21:36
【问题描述】:
我正在使用 springboot 和 thymeleaf 映射以在 html 页面上显示我的数据库中的数据。
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" />
<title></title>
<link rel="stylesheet" type="text/css" th:href="@{/assets/style.css}" />
</head>
<body>
<p th:text="${title}"></p>
<a href="/newPost">Create a new Post</a>
<a href="/newComment">Create a new Comment</a>
<table>
<tr th:each="post : ${posts}">
<td th:text="${post.creationDate}"></td>
<td th:text="${post.titel}"></td>
<td th:text="${post.content}"></td>
<td><a th:href="@{/newComment(postId=${post.id})}">new Comment</a></td>
<td th:text="${post.comments}"></td>
<td><img th:src="${post.bild}"></td>
</tr>
</table>
我使用 DTO 来映射实体,但是当显示实际的 html 页面时,图像不显示(404 错误),即使在我检查标签时显示链接。
我是否遗漏了一些明显的东西?如果我不想将它们转换为字节流,这不是在我的页面上显示图像的简单方法吗? 我猜您需要更多信息,但我不知道哪个会有所帮助。任何帮助表示赞赏!
【问题讨论】:
标签: html mysql spring-boot thymeleaf heidisql