繁体   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