Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot ThymileAF:无法作为表达式进行分析_Spring Boot_Thymeleaf - Fatal编程技术网

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