哎呀,真是痛苦啊,用以前用过的方式进行循环遍历,总是报错,代码和错误如下:
代码:
<#list stringMap?keys as strKey>
<#list stringMap[strKey] as system>
${system}
</#list>
</#list>
错误:
: Request processing failed; nested exception is : Getting the number of items or enumerating the items is not supported on this method+sequence (wrapper: ) value.
(Hint 1: Maybe you wanted to call this method first and then do something with its return value. Hint 2: Getting items by intex possibly works, hence it’s a “+sequence”.)
真的是让人头疼,找了两个小时也没有找到错误,我真是没有折了,折腾了半天,结果打印出来的key值你真的是想象不到:
key值:
getClass getOrDefault computeIfAbsent values replace replaceAll remove containsValue put empty compute hashCode putAll get merge class keySet abc entrySet forEach containsKey isEmpty clear computeIfPresent size equals clone toString putIfAbsent
想象不到吧,竟然把map自带的方法打印出来了,这当然是错的了,所以我就像大多数的程序猿一样,继续去网上找答案,终于皇天不负有心人啊,找到了解决办法,代码如下:
<#list () as strKey>
<#list stringMap[strKey] as system>
${system}
</#list>
</#list>
虽然是一个小错误或者是小知识,也浪费了lz不少的时间,希望我在这里提供出来,能帮大家避免这个坑!