modelAndView.addObject("loginUser", user);
loginUser里面有username属性
当我们想获取username时,需要加上if判断,即判断loginUser不为null
<th:block th:if="${loginUser!= null}">
<p th:text="${loginUser.username}"></p>
</th:block>
Thymeleaf之SpelEvaluationException: EL1007E: Property or field '***' canno be found on null
原文:https://www.cnblogs.com/da-hao/p/13164596.html