1
我正在使用thymeleaf作爲UI框架。我從數據庫中提取數據並將其作爲對象存儲。當我在表格中顯示我的值時,我有一些空白的單元格。而不是它是空白我怎樣才能輸入值爲「NULL」如何在thymeleaf中將值設置爲「NULL」
<table>
<tr>
<th>id</th>
<th>name</th>
<th>age</th>
<th>years in school</th>
</tr>
<tr th:each="student : ${studentinfo}">
<td th:text = "${student.id}"></td>
<td th:text = "${student.name}"></td>
<td th:text = "${student.age}"></td>
<td th:text = "${student.years}">NULL</td>
//attempted
<td th:text = "${student.years != null} ? ${student.years}">NULL</td>
</tr>
</table>
有些學生多年無效。但是當我在UI中顯示它時,它只是一個空白單元格。如果單元格爲空白,我想顯示「NULL」。