首页 > 解决方案 > Spring-Boot Thymeleaf 以 html 格式加载图像,列表不显示

问题描述

我正在使用 Spring-Boot Thymeleaf 制作带有上传菜单(图像)的小应用程序,我的上传菜单正在工作,所以列表菜单上传,但问题是当我尝试将我的图像从 netbeans 中的静态文件夹显示到网页时,我的文件名是出现,但我的形象没有。应该怎么样?

我从之前创建的列表菜单中获取文件数据图像。

//这是来自我的 list.html:

<table border='1' width='50%' height='100%'>
        <tr th:each="files: ${fileName}">
        <td th:text="${files}"/>
        <td><img src="../static/img/ "width="100"
         th:src="@{img/' + files + '}"/></td>

        </tr>    

我希望网页上的输出是我的文件名(来自图像)和图像显示。

标签: javahtmlspringspring-bootthymeleaf

解决方案


你的 th:src 接缝是错误的。它应该是

<img th:src="@{'/img/'+ ${files}}">

推荐阅读