目录
Thymeleaf语法(最常用)
-
获取变量值${...}
<!--不转义--> <div th:text="${msg}"></div> <!--转义--> <div th:utext="${msg}"></div>
-
链接表达式: @{…} ,类似的标签有:
th:href
和th:src
<a href="details.html" th:href="@{/order/details(orderId=${o.id})}">view</a>
-
循环
model.addAttribute("users", Arrays.asList("aaa","bbb"));
<h2 th:each="user:${users}" th:text="${user}"></h2> <!--<h2 th:each="user:${users}">[[${user}]]</h2>-->
如何去除idea中thymeleaf模板中飘红问题
打开设置
选择editor,然后打开Inspections
搜索thymeleaf然后将Expression variables validation选项后面的勾选框去掉,最后点击应用
飘红已经消失