【发布时间】:2021-11-10 19:14:18
【问题描述】:
我正在使用 Spring Boot 和 Thymeleaf 制作体育电子商务网站,并且在特定产品的产品页面和编辑页面的索引中,我无法查看产品的图像。 This is how the edit a product page (inspect on Chrome) looks
这是编辑产品的 HTML 代码。当前图像下方的行是为编辑和索引生成错误的行。
<div class="form-group">
<label for="">Image:</label>
<input type="file" class="form-control" th:name="file" th:id="file">
<img class="mt-2" src="#" alt="" id="imgPreview1">
<br><br>
<label for="">Current image:</label>
<img style="width: 100px;" th:src="@{'media/'+${product.image}}">
</div>
我从 src/main/resources/static/media 的媒体文件夹中获取图像,并从数据库中获取产品名称。从数据库中获取图像文件的名称没有错误。它看起来像一个路径错误,但我似乎无法弄清楚。
【问题讨论】:
标签: html spring spring-boot image thymeleaf