标准表达式语法
${…} : 变量表达式。
*{…} : 选择表达式。
#{…} : 消息 (i18n) 表达式。
@{…} : 链接 (URL) 表达式。
~{…} : 片段表达式。
获取变量
<td>[[${year}]]</td>
<input id="year" style="display: none" th:value="${year}">
<span th:text="${book.author.name}">
//一个对象多个属性
<form method="post" id="form-evaluationInfo-edit" class="form-horizontal"th:object="${evaluationreviewpo}">
<input id="guid" name="guid" th:field="*{guid}" type="hidden">
<input id="projectId" name="guid" th:field="*{projectId}" type="hidden">
</form>
//1.获取对象属性
[[ ${user.userName} ]]
//2.获取集合中的元素(下标)
[[ ${users[0].userName} ]]
//3.获取Map中的元素(key)
[[ ${ userMap{'user1'}.userName } ]]
//获取数组中的元素(下标)
[[ ${userArr[0].userName} ]]
遍历
1.集合遍历成多个超链接
<a href="javascript:;" class="ellipsis" onclick="TZdetail(0)" th:each="list : ${list}" th:text="${list.name}">
</a>
2.遍历成select的多个选项
<select name="year" id="year" class="form-control m-b" th:with="type=${@dict.getType('year_choosing')}"
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
3.遍历成表格的多行
<tr th:each="verify : ${verifies}">
<td clss="text-nowrap">[[${verify.verifyRole}]]</td>
<td class="text-nowrap">[[${verify.verifyUserName}]]</td>
<td class="text-nowrap">[[${verify.generalOpinion}]]</td>
<td clss="text-nowrap" th:text="${#dates.format(verify.verifyTime, 'yyyy-MM-dd hh:mm:ss')}"></td>
</tr>
超链接带modal值
th:href="@{'字符串'+${model中的nam值}}"
<a th:href="@{'/dataImport/downTemplate/'+${importType}}" >[[${importType}]]模板下载</a>