Spring boot ThymileAF:无法作为表达式进行分析
我试图制作一个表,显示数据库中的信息,包括一个图像。问题是如何显示图像:Spring boot ThymileAF:无法作为表达式进行分析,spring-boot,thymeleaf,Spring Boot,Thymeleaf,我试图制作一个表,显示数据库中的信息,包括一个图像。问题是如何显示图像: <table> <tr> <th>ID Catégorie:</th> <th>Nom:</th> <th>Description:</th> <th>Photo:</th> </tr> <tr th
<table>
<tr>
<th>ID Catégorie:</th>
<th>Nom:</th>
<th>Description:</th>
<th>Photo:</th>
</tr>
<tr th:each="cat : ${categories}">
<td><img th:src="photoCat?idCat=${cat.idCategorie}"/></td>
</tr>
</table>
我得到以下错误:
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "photoCat?idCat=${cat.idCategorie}" (categories:53)
你能帮忙吗?谢谢。您不能在Thymeleaf中嵌入这样的变量 请尝试以下方法:
<img th:src="${'photoCat?idCat=' + cat.idCategorie}" />
<img th :src="${image soruce url}" />
我建议百里香叶url语法添加任意数量的参数 比如说,
<img th:src="@{/photoCat(idCat=${cat.idCategorie}}" />
它将生成如下URL:photoc?idCat=类别
<img th:src="@{/photoCat(idCat=${cat.idCategorie},q=${query}}" />
它将生成如下URL:photopic?idCat=category&q=query
<img th:src="@{/photoCat(idCat=${cat.idCategorie},q=${query}}" />
它还将为您对所有变量进行URI编码
查看文档了解更多示例。您必须像这样放置图像源url