含雪幸福

导航

 
1 <div th:with="param1=1">
2  <a th:href="@{/link(p1=${param1})}">link</a>
3 </div>

 

 

 

 

【thymeleaf】模板中定义变量

  th:with 定义变量

  

使用 th:with 定义变量。形如:

1 <th:block th:with="var1=1"></th:block>
2 <div th:with="var1=1"></div>
3 ...

使用方式如下:

1 <div th:with="param1=1"> 
2   <a th:href="@{/link(p1=${param1})}">link</a>
3 </div>

=================================================================

例如: 登录人对应的省份:北京, 列表下所有省份数据, 只有省份为:登录人的省份, 此数据[删除]按钮才可用

controller
model.addAttribute("provinceCode", getCurrentUser().getDataPermProvince().get(0));// 
model.addAttribute("caseFileList", reportService.selectCaseBaseManageList(caseFile, getCurrentUser(), pageInfo));


html
<tr th:each="order, status: ${caseFileList}">
 <td align="center">
    <div th:with="provCode = ${provinceCode}">
    <a th:unless="${order.provCode eq provCode}"
    style="color:gray; text-decoration:none;" href ="javascript:return false;">&nbsp;</a>
     <a th:if="${order.provCode eq provCode}"
       href="javascript:void(0);" data-toggle="modal"
      th:onclick="'javascript:deleteConfirm(\''+${order.id}+'\',\''+${order.provName}+'\',\''+${order.caseType}+'\',\''+${order.caseFileName}+'\',\''+${order.uploadUser}+'\',\''+${#dates.format(order.submitTime,'yyyy-MM-dd')}+'\')'"
       data-target="#deleteConfirmModal">
      
      </a>
    </div>
  </td>
</tr>
 





 

 
posted on 2020-12-29 15:08  含雪幸福  阅读(4904)  评论(1编辑  收藏  举报
 
/*生成博客目录的CSS*/ #uprightsideBar{ font-size:12px; font-family:Arial, Helvetica, sans-serif; text-align:left; position:fixed;/*将div的位置固定到距离top:50px,right:0px的位置,这样div就会处在最右边的位置,距离顶部50px*/ top:50px; right:0px; width: auto; height: auto; } #sideBarTab{ float:left; width:30px; border:1px solid #e5e5e5; border-right:none; text-align:center; background:#ffffff; } #sideBarContents{ float:left; overflow:auto; overflow-x:hidden;!important; width:200px; min-height:108px; max-height:460px; border:1px solid #e5e5e5; border-right:none; background:#ffffff; } #sideBarContents dl{ margin:0; padding:0; } #sideBarContents dt{ margin-top:5px; margin-left:5px; } #sideBarContents dd, dt { cursor: pointer; } #sideBarContents dd:hover, dt:hover { color:#A7995A; } #sideBarContents dd{ margin-left:20px; }