Reason for error:
username cannot be empty
Solution:
The original code:
<span th:text="${session.user.username}"></span>
Code after change:
<span th:text="${session.user?.username}"></span>
Why add one? Can be solved
Because this is a thymeleaf method to determine whether the object is empty. thymeleaf shows that an object uses ${username}, but if the username is null, thymeleaf will report an error.