我有问题。我想显示文本时的值不为空。
<tr th:each="user : ${users}">
<td>
<span th:text="${user.display} ? ${user.display} : 'null value!'"> NOW is work</span>
</td>
</tr>
我想你可以使用1个变量表达式${}
了点。
尝试
<tr th:each="user : ${users}">
<td>
<span th:text="${user.display != null || user.display != '' ? user.display : 'null value!'}"> NOW is work</span>
</td>
</tr>
编辑
我只注意到你怎么做你的病情,所以我已经编辑我的答案。也没有什么错,你怎么使用变量表达式,是我不好。
什么是user.display的价值?我认为它没有布尔,因为如果它是你的方式做你的情况是错误的。
${user.display} ? ${user.display} : 'null value!' // true if the value of user.display is boolean **true**
${user.display != null || user.display != ''} ? ${user.display} : 'null value!'} // true if the value of user.display is not null or not '' empty string
尝试
<tr th:each="user : ${users}">
<td>
<span th:text="${user.display != null || user.display != ''} ? ${user.display} : 'null value!'}"> NOW is work</span>
</td>
</tr>