我试图制作一张表格,显示来自数据库的信息,包括图像。问题是如何显示的图像:Thymeleaf:无法解析为表达式
<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>
我对显示图像控制器方法:
@RequestMapping(value="photoCat",produces=MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public byte[] photoCat(Long idCat) throws IOException{
Categorie c=adminCatService.getCategorie(idCat);
return org.apache.commons.io.IOUtils.toByteArray(new ByteArrayInputStream(c.getPhoto()));
}
,我发现了以下错误:
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "photoCat?idCat=${cat.idCategorie}" (categories:53)
你能帮请?谢谢。
谢谢,这解决了我的问题 – METTAIBI