如何在Velocity中创建和访问多级地图?

时间:2015-10-01 16:08:57

标签: apache velocity

我想为每个条目创建一个包含多个值的动态地图,然后能够在该地图上运行并将值与另一个列表匹配。这就是我的意思:

#set($map = {})

#foreach( $Item in $someQuery.getResults() )

  #set( $day = "Monday") ## This would be a dynamic value.. just example here

  #set( $startTimeHour = "8")
  #set( $startTimeMinute = "00")

  #set( $endTimeHour = "17")
  #set( $endTimeMinute = "30")

  ## Now I need here to put this into a map...
  $!map.put("${foreach.count}", "dayValue": $day, "startTimeHourValue": $startTimeHour, "startTimeMinuteValue": $startTimeMinute, "endTimeHourValue": $endTimeHour, "endTimeMinuteValue": $endTimeMinute)

#end

With this, I want to be able to do this in another for each loop

#foreach($newItem in $someList)

    #if($newItem.DayValue IS IN MAP DAY VALUE $map.dayValue????)
        ## Print everything associated with this map entry
            $map.dayValue
            $map.startTimeHourValue
            $map.startTimeMinuteValue
            $map.endTimeHourValue
            $map.endTimeMinuteValue
    #end

#end

我对速度很新,没有Java知识,所以任何帮助都会非常感激。谢谢!

0 个答案:

没有答案