thymeleaf -常见用法

版权声明:[ws - 兮的博客] - 空间专属,未经声明不得私自转载 https://blog.csdn.net/qq_41463655/article/details/83987502

空值处理
取值如:file?name 不会报错

thymeleaf的循环 //循环,取值使用 file.???

<tr th:each="file:${files}"><tr>      

事件传单值------ user_update为方法名

 <button th:onclick="|user_update('${u.userId}')|" > </button> 

事件传多值

 <button th:onclick="|playfile(filepath='${file.pathfile}',name='${file.name}')|" > </button>

a连接传单值

<a th:href="@{/user/deleteId(id=${u.userId})}"</a>    

a连接传多值

<a th:href="@{/file/deleteId(id=${file.fileId},pathfile=${file.pathfile})}"></a>  

小数保留2位

<td th:text="${#numbers.formatDecimal(file.size,0,2)}">KB</td>     

时间类型

  <td th:text="${#dates.format(file.time,'yyyy-MM-dd HH:mm:ss')}"></td>  

自动赋值被勾选状态------- role.isExe = ‘yes’ 的

<input type="checkbox" th:value="${role.roleId}"  th:checked="${role.isExe eq 'yes' }"> 

select 后台取值回显数据

<select name="dep.depId">
    <option  th:each="dep:${deps}"  th:value="${dep.depId}" th:text="${dep.name}" value="1"></option>
</select>

select 联表复杂数据回显数据

<select  class="orderType" style="width: 190px;height:38px" >
    <option  th:selected="${dateil.orderGoods.orderType.orderTypeId eq type.orderTypeId}"      th:each="type:${dateil.orderGoods.orderType.orderFirm.orderTypeList}"     th:value="${type.orderTypeId}" th:text="${type.name}" value="1"></option>
</select>

多判断 可 ||

 th:if="${order.type == '运输单' && state != null && state != '' 

猜你喜欢

转载自blog.csdn.net/qq_41463655/article/details/83987502
今日推荐