简体   繁体   English

如何在Mvel中迭代地图

[英]How to iterate over a map in mvel

I have a collection (map) which I want to use with the foreach orb tag. 我有一个要与foreach orb标记一起使用的集合(地图)。

How do i do this in mvel and is it also possible to get the current key? 我如何在Mvel中做到这一点,也有可能获得当前的钥匙?

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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM