2016-12-06 2 views
1

Я использую #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. Итак, как мне решить эту проблему? Благодаря

ответ

1

Нет, проблема (цитата из сообщения об ошибке):

Method substr [...] cannot be found on org.thymeleaf.expression.Strings type

Это означает, что #strings не имеет метод, называемый substr. Вероятно, вы имеете в виду substring.

http://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#strings

+0

Thanks. Я так глуп для этого. :( – user2125722

Смежные вопросы