Javascript thymeleaf上的window.location.href
我的Thymeleaf模板中有这段代码,但它不能正常工作,因为这是生成的位置Javascript thymeleaf上的window.location.href,javascript,html,thymeleaf,Javascript,Html,Thymeleaf,我的Thymeleaf模板中有这段代码,但它不能正常工作,因为这是生成的位置 deviceevent/@%7B/deviceevent/list/%7Bid%7D(id=$%7BdeviceEvent.id%7D)%7D 在模板中 <tr th:each="deviceEvent : ${deviceEvents}" onclick="window.location.href = '@{/deviceevent/list/{id}(id=${deviceEvent.id})}'" &g
deviceevent/@%7B/deviceevent/list/%7Bid%7D(id=$%7BdeviceEvent.id%7D)%7D
在模板中
<tr th:each="deviceEvent : ${deviceEvents}" onclick="window.location.href = '@{/deviceevent/list/{id}(id=${deviceEvent.id})}'" >
Thymeleaf不计算属性,除非它们的前缀是
th
。在本例中,th:onclick
。完整的字符串应如下所示:
th:onclick="'window.location.href = \'' + @{/deviceevent/list/{id}(id=${deviceEvent.id})} + '\''"