在Java中:
Map<String, Object> model = new HashMap<>();
Map<String, String> items = new HashMap<>();
items.put("color", "red");
model.put("items", items);
如果items
包含密钥color
,我现在想要在我的呈现模板中包含一个代码段。
<#if ???? >
the map contains a key called color
</#if>
我该怎么替换????与?
答案 0 :(得分:11)
您可以像这样使用??
运算符:
<#if items['color']?? >
the map contains a key called color
</#if>