in velocity can you iterate through a java hashmap's entry set()?

前端 未结 4 1065
傲寒
傲寒 2021-02-01 12:52

Can you do something like this in a velocity template?

#set ($map = $myobject.getMap() )
#foreach ($mapEntry in $map.entrySet())
    $mapEntry.key()&         


        
4条回答
  •  梦毁少年i
    2021-02-01 13:31

    Here the Value

    itemsValue={data1=1,data2=2,data3=3}
    

    So , we need to iterate the group of value;

    foreach ($key in ${itemsValue.keySet()})
       if($itemsValue.get($key)==1)
            Condition
       end
    end
    

    In the above code we can see check the value will be like -"data1,data2 etc ..." but after using the get(), we can able to get the instance value.

提交回复
热议问题