Thymeleaf 使用路径变量到 th:href

Thymeleaf 使用路径变量到 th:href

问题描述:

这是我的代码,我正在迭代:

Here's my code, where I'm iterating through:

<tr th:each="category : ${categories}">
     <td th:text="${category.idCategory}"></td>
     <td th:text="${category.name}"></td>
     <td>
         <a th:href="@{'/category/edit/' + ${category.id}}">view</a>
     </td>
</tr>

它指向的 URL 应该是 /category/edit/,但它说它无法解析表达式:

The URL it points to is supposed to be /category/edit/<id of the category>, but it says it could not parse the expression:

评估 SpringEL 表达式的异常:category.id"(类别列表:21)

Exception evaluating SpringEL expression: "category.id" (category-list:21)

根据用于添加参数的 Thymeleaf 文档 是:

<a th:href="@{/category/edit/{id}(id=${category.idCategory})}">view</a>