pis*_*hio 4 java templates freemarker
我有一个Map,其键和值以及自定义类.调用密钥类,Position并使用两个int进行实例化(例如new Position(2, 4).
我摆脱了这个Position类并将地图转换为a SimpleHash以便与Freemarker一起使用.我现在有一个SimpleHash键为字符串重新映射位置值(例如"2 4"),其值是null或Lot(自定义)类.
在模板中,我需要检查SimpleMap中给定项的值(传递为map)是null还是Lot实例.
<#list mapMinY..mapMaxY as y>
<tr>
<#list mapMinX..mapMaxX as x>
<td>
<div>
<!-- Check if map[x + " " + y] is null -->
${x}, ${y}
</div>
</td>
</#list>
</tr>
</#list>
Run Code Online (Sandbox Code Playgroud)
这该怎么做?
使用??运营商.
<#if map[x + " " + y]??>It's not null<#else>It's null or missing</#if>
Run Code Online (Sandbox Code Playgroud)
另见手册的相关部分.