{"title":"Spring Boot Thymeleaf 图片显示:如何在HTML中显示数据库图片?","description":"本文介绍了如何在Spring Boot项目中使用Thyleaf模板引擎,从数据库读取图片并显示在HTML页面上。详细讲解了图片存储路径、HTML代码示例以及图片路径设置方法。","keywords":"Spring Boot, Thymeleaf, 图片显示, 数据库图片, HTML, 图片路径, 文件夹","content":""html写了\t\t\t<div class="box" th:each="good:${GoodsList}">\n\t\t\t\t<div class="image">\n\t\t\t\t\t<img th:src="@{'/download?filepath='+${good.pic}}" alt="加载失败,请重新尝试"\n\t\t\t\t\t\theight="200" width="200">\n\t\t\t\t

\n数据库表里有goods表,里面有tomato.jpg。这张tomato.jpg要放到哪里才能显示出来内容:要在html文件所在的目录下创建一个名为"download"的文件夹,并将"tomato.jpg"放入该文件夹中。然后在标签的th:src属性中设置路径为"download/tomato.jpg",即可显示出来。"}


原文地址: https://www.cveoy.top/t/topic/p38R 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录