引入css和js文件
1 | <link th:href="@{/resources/admin/css/common.css}" rel="stylesheet" type="text/css" /> |
网页标题(多语言)
使用#{key}1
2
3
4
5
6
7
8 <title th:text="#{system.name}"></title>
# thymeleaf结合js
<script th:inline="javascript">
//controller 使用Model设置属性
var error=[[${error}]];
//多语言
var usernameRequired=[[#{admin.login.usernameRequired}]]
</script>
thymeleaf结合js 冲突
1 | //使用<![CDATA[ ]]> |
th:include
compontent/commonJs.html1
2
3
4
5<div th:fragment="commonJs">
<script th:inline="javascript">
js代码(国际化语言)
</script>
</div>
引用1
<div th:include="compontent/commonJs::commonJs"></div>
th:href
1 | <a th:href="@{/admin/publicInfo/info(id=${publicInfo.id})}" target="iframe" th:text="#{admin.menu.publicManage.name}"></a> |
th:each
1 | <tr th:each="admin:${page.content}"> |
格式化日期
1 | <td th:text="${#calendars.format(admin.createDate,'yyyy年MM月dd日')}"></td> |
th:if
• 单个条件1
<td th:if="${admin.username}=='admin'"><input type="checkbox" name="ids" th:value="${admin.id}" disabled="disabled"/></td>
• 并且条件1
2
3
4<td th:if="${session.username}!='admin' and ${admin.username}==${session.username}">
<a th:href="@{initEdit(id=${admin.id})}" th:text="#{admin.menu.admin.edit}">
</a>
</td>