Thymeleaf

标准表达式语法

${…} : 变量表达式。
*{…} : 选择表达式。
#{…} : 消息 (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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

飘然生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值