【发布时间】:2020-05-05 05:27:54
【问题描述】:
当使用 Thymeleaf 在 Select 上选择选项时,我正在尝试重定向我的页面。我的代码是这样写的:
<select>
<option th:each="size : ${pageSizes}" th:text=${size} th:onclick="'window.location.href = \'' + @{/ingredient(size=${size})} + '\''"></option>
</select>
而且,在谷歌浏览器上检查后,创建的 HTML 是:
<select>
<option onclick="window.location.href = '/ingredient?size=5'">5</option>
<option onclick="window.location.href = '/ingredient?size=10'">10</option>
<option onclick="window.location.href = '/ingredient?size=20'">20</option>
<option onclick="window.location.href = '/ingredient?size=25'">25</option>
<option onclick="window.location.href = '/ingredient?size=50'">50</option>
</select>
但在选择一个新选项时,没有任何反应。我做错了什么?
【问题讨论】:
标签: html spring-boot spring-mvc thymeleaf