解决thymeleaf th:value当值为null时报错的问题

方法一:三目运算符

 <input type="text"  th:value="${userInfo!=null ?userInfo.phone:''}">
                                           

方法二:*{ xx },后台数据要设置为内置对象

 <input type="text" class="form-control" th:value="*{qq}">

建议方法一,简单粗暴

posted @ 2020-03-27 17:25  9529  阅读(4364)  评论(1)    收藏  举报