【thymeleaf】模板中定义变量


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>
 





 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM