在 Java 中:
Map<String, Object> model = new HashMap<>();
Map<String, String> items = new HashMap<>();
items.put("color", "red");
model.put("items", items);
如果
items
,我现在想在渲染模板中包含一个片段包含 key color
.<#if ???? >
the map contains a key called color
</#if>
换什么????和?
最佳答案
您可以使用 ??
像这样的运算符:
<#if items['color']?? >
the map contains a key called color
</#if>
关于freemarker - 检查 map 是否包含 Freemarker 中的特定键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40771868/