【发布时间】:2018-04-27 00:17:01
【问题描述】:
我正在尝试在 javascript 中使用 thymeleaf。 当我将 th:each 与 html 一起使用时,我的代码工作正常
<table>
<tr th:each="theme : ${les_themes_1}">
<td th:text="${theme.id}">id</td>
</tr>
</table>
但是当我在脚本中使用 forEach 时,它返回 null
<script th:inline="javascript" >
/*<![CDATA[*/
/*[# th:each="theme : ${les_themes_1}"]*/
document.write(/*[[${theme}]]*/); //return null
document.write(/*[[${theme.id}]]*/); //not working
/*[/]*/
/*]]>*/
</script>
请帮助!谢谢!
【问题讨论】:
-
您的示例适用于百里香叶 3...
-
我用的是thymeleaf 2.1.3版本!我会尝试更改版本
-
用 thymeleaf 3 工作正常,谢谢你的回答!
标签: javascript spring thymeleaf