I'm trying to populate a thymeleaf template with some data from Spring Boot. What I'm trying to do is this
<tr th:if="${group.organization}">
<td class="col_title"><b>Organization:</b></td>
<td class="organization-field-content" th:text="${group.organization}"></td>
</tr>
I've tried both the solutions proposed here:
Thymeleaf: show text if the attribute and property exists
and, following the render order of thymeleaf, since the group.organization
is null, the entire inner td
s should not be displayed.
Still there a problem because Thymeleaf complains saying
Servlet.service() for servlet [dispatcherServlet] in context with path []
threw exception [Request processing failed; nested exception is
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating
SpringEL expression: "group.organization" (group)] with root cause
java.lang.NullPointerException: null
I don't understand why this is happening, since the group object exists, just the organization is null