Tag Archives: EL1007E: Property or field ‘xxx’ cannot be found on null

EL1007E: Property or field ‘xxx’ cannot be found on null

If the object itself is empty, an error will be reported when the attribute of the object is retrieved from the session

Solution:
original code:

< span th:text=”${session.user.username}”>& lt;/ span>

After change:

< span th:text=”${session.user?.username}”>& lt;/ span>

Why add one?You can solve
because this is a method for thymeleaf to judge whether the object is empty. Thymeleaf shows that an object uses ${username}, but if the username is null, thymeleaf will report an error