春と一緒に thymeleaf を使用していますが、次の html セグメントを解析するときにエラーが発生します
<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
には 1 つのプロパティが含まれます。branch
これもエンティティであり、1 つのプロパティが含まれます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
なにが問題ですか?Thymeleaf の設定で何か不足していますか?