Я использую thymeleaf вместе с пружиной и есть ошибка при разборе следующего HTML сегментаorg.springframework.expression.spel.SpelEvaluationException - Свойство или поле не может быть найдено на нуле
<tbody>
<tr th:each="item:${systemUsers}">
<td th:text="${item.username}"/>
<td th:text="${item.fullName}"/>
<td th:text="${item.mobile}"/>
<td th:text="${item.enabled}"/>
<td th:text="${item.manGrade}"/>
<td th:text="${item.branch.branchName}"/>
<td>
<a th:href="@{/users/detail/{id}(id=${item.id})}" class="btn btn-info">Details</a>
</td>
<td>
<a th:href="@{/users/edit/{id}(id=${item.id})}" class="btn btn-danger">Edit</a>
</td>
</tr>
</tbody>
Объект systemuser
содержит одно имущество branch
, которое также является юридическим лицом и содержит одно имущество branchName
. Но при рендеринге html возникает ошибка
2016-07-14 10:07:31.114 ERROR 8088 --- [nio-8080-exec-1] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-8080-exec-1] Exception processing template "systemusers/list": Exception evaluating SpringEL expression: "item.branch.branchName" (systemusers/list:38)
2016-07-14 10:07:31.116 ERROR 8088 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/crpms] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "item.branch.branchName" (systemusers/list:38)] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 0): Property or field 'branchName' cannot be found on null
Что не так? Я что-то упустил в конфигурации Тимелеафа?
Вставьте код в виде кода, а не как изображение. – sanluck
@sanluck OK, спасибо, что напомнил. Я первый раз задаю вопрос в stackoverflow. – lupper