How to iterate over a map in mvel

╄→гoц情女王★ 提交于 2019-12-12 05:14:46

问题


I have a collection (map) which I want to use with the foreach orb tag.

How do i do this in mvel and is it also possible to get the current key?


回答1:


Map<Integer, Integer> map = new HashMap<Integer, Integer>();

//java
for (Map.Entry<Integer, Integer> entry : map.entrySet()) 
{
    System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}

//mvel
foreach (c : map.entrySet) 
{

   System.out.println("Key = " +c.key + ", Value = " +c.value);
}


来源:https://stackoverflow.com/questions/9284734/how-to-iterate-over-a-map-in-mvel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!