Thymeleaf是一个Java模板引擎,支持html、xml、text、javascript、css、raw这几种模型。 使用Thymeleaf首先需要引入命名空间
<html xmlns:th="http://www.thymeleaf.org">使用th:each做循环迭代,并使用${对象.属性}来访问具体的值
判断是否为空 <tr th:if="${messages.empty}"> <td colspan="3">No messages</td> </tr> 在Javascript中访问model模型数据 <script th:inline="javascript"> var user = [[${user}]] console.log(user.name + "\t" + user.age); </script>通过添加th:inline=”javascript”到script标签来访问model模型数据 通过”[[${}]]”这种格式来获取具体的值