簡體   English   中英

Thymeleaf 中的條件

[英]Conditionals in Thymeleaf

我的 Thymeleaf 模板中有這段代碼

<INPUT TYPE="text" TH:VALUE="${searchForm.male}" />
<span th:if="${searchForm.male == 'true' }">
   IS TRUE
</span>
<span th:unless="${searchForm.male == 'true'}">
   IS NOT TRUE
</span>

但這就是我所看到的:

在此處輸入圖像描述

如果男性屬性是 boolean 只需刪除引號如下

<input type="text" th:value="${searchForm.male}"/>
<span th:if="${searchForm.male == true }">IS TRUE</span>
<span th:unless="${searchForm.male == true}">IS NOT TRUE</span>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM