【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