【发布时间】:2016-01-21 03:03:42
【问题描述】:
我正在尝试制作一个表格,显示来自数据库的信息,包括一张图片。问题是如何显示图像:
<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)
你能帮忙吗?谢谢。
【问题讨论】:
标签: spring-boot thymeleaf