我使用#strings.substr()
功能,它提供了以下錯誤:Thymeleaf - 異常評估SpringEL表達
There was an unexpected error
(type=Internal Server Error, status=500)
. Exception evaluating SpringEL expression:"#strings.substr(status,iter.index,iter.index+1)"
(init:37)
這是代碼:
<tbody>
<tr th:each="task,iter : ${taskList}">
<td th:text="${task.id}"></td>
<td th:text="${task.task}"></td>
<td th:switch="${#strings.substr(status,iter.index,iter.index+1)}">
<div th:case="'0'"> <input type="checkbox"/> </div>
<div th:case="'1'"> <input type="checkbox" checked = "checked" /> </div>
<div th:case="*"> <input type="checkbox" id = "checkbtn" checked = "checked"/> </div>
</td>
</tr>
</tbody>
這是錯誤日誌:
Exception evaluating SpringEL expression: "#strings.substr(status,iter.index,iter.index+1)" (init:37)] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 9): Method call: Method substr(netgloo.models.Exit,java.lang.Integer,java.lang.Integer) cannot be found on org.thymeleaf.expression.Strings type
我想這個錯誤是由於事實iter.index是整型,函數期望int。那麼我該如何解決這個問題呢?由於
謝謝。我因爲錯過了這個東西而覺得很愚蠢。 :( – user2125722