我正在使用springboot和thymeleaf映射以在html页面上显示数据库中的数据。 我使用了DTO来映射实体,但是,当显示实际的html页面时,即使在我检查标签时显示链接,也没有显示图像(404错误)。 我缺少明显的东西吗?如果我不想将图像转换为字节流,这不是在页面上显示图像的简便方法吗?
我猜您需要更多信息,但我不知道这会有所帮助。任何帮助表示赞赏! 答案 0 :(得分:0) 无法从在Web服务器上运行的网页访问本地文件系统。有关详细信息,请参见this answer。<!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>
1 个答案: