遍历嵌套数据结构
渲染map 中value是list的内容
<#if nodes?? && (nodes?size>0) >
【节点明细】<#list nodes?keys as alarmLevel>${alarmLevel + ":"}<#if (nodes[alarmLevel])??><#list (nodes[alarmLevel]) as node>${node.nodeNo}<#sep>,</#list></#if> </#list>
</#if>
说明
- 判断nodes是否为null,并判断nodes是否为空map
表达式中调用变量的判断逻辑不能用$符号,必须用()包起来使用 - map的遍历获取key
<#list nodes?keys as alarmLevel>${alarmLevel + ":"}
</#list>
- 通过获取到的key和map获取value
nodes[alarmLevel] 这个写法用()包起来,放到表达式里才能生效
遍历map的value
<#if (nodes[alarmLevel]) as node>
</#if>
<#if (nodes[alarmLevel])??>
<#list (nodes[alarmLevel]) as node>
${node.nodeNo}<#sep>,
</#list>
</#if>
- <#sep>, 指定每次遍历结尾是,并且最后一次遍历没有结尾符