其他分享
首页 > 其他分享> > Thymeleaf之SpelEvaluationException: EL1007E: Property or field '***' canno be found on null

Thymeleaf之SpelEvaluationException: EL1007E: Property or field '***' canno be found on null

作者:互联网

modelAndView.addObject("loginUser", user);

loginUser里面有username属性

当我们想获取username时,需要加上if判断,即判断loginUser不为null
<th:block th:if="${loginUser!= null}">

  <p th:text="${loginUser.username}"></p>

</th:block>

标签:username,addObject,canno,field,loginUser,null
来源: https://www.cnblogs.com/da-hao/p/13164596.html