【发布时间】:2023-03-31 13:00:02
【问题描述】:
我是 Thymeleaf(和 webdev)的新手,我正在尝试将 Thymeleaf 迭代 (th:each) 与 URL 重写 (th:href) 结合起来。
<a th:each="lid : ${lists}" th:text="${lid}" th:href="@{/list?l=${lid}}">
hello
</a>
这会产生以下结果(其中 lid=45):
<a href="/list?l=${lid}">45</a>
所以,它在 th:text 上进行了替换,但在 th:href 上没有。
我不想做任何形式的 URL 重写,我只是使用 '@' 语法,因为我希望 Thymeleaf 替换 'lid' 属性。
我在 Google App Engine 中使用当前版本的 Thymeleaf (2.1.2)。
【问题讨论】: