【发布时间】:2018-05-03 17:10:13
【问题描述】:
我有一个 Mongodb 文档,例如:
Document document = new Document()
document.append("_id", 1);
document.append("isTrue", true); //this is optional
我如何在 Thymeleaf 中打印它。
<td th:text="${document.isTrue}"></td>
所以,由于 isTrue 是可选的,所以有时 isTrue 存在有时不存在。当 document.isTrue 存在时它工作正常,但当不存在时 Thymeleaf 给出错误
Exception evaluating SpringEL expression: "document.isTrue"
虽然我期望它应该打印 null,因为当给定值不存在键匹配时,mongodb 文档返回 null。
【问题讨论】:
标签: spring spring-mvc thymeleaf