others

Velocity에서의 Map 사용

aircook 2009. 11. 24. 09:28

다음과 같이 사용하면 됩니다.

#set ($portalMap = {"NAVER" : "http://www.naver.com/", "DAUM" : "http://www.daum.net/", "NATE" : "http://www.nate.com/", "YAHOO" : "http://kr.yahoo.com/"})

#foreach ( $entry in $portalMap.entrySet())

          <li>$velocityCount.<a href="$entry.getValue()"  target="_blank">$entry.getKey()</a></li>

#end

 추가로 $, # 같은 특수문자를 사용하기 위해서는 \#parse ("\$test.vm") 같이 "\" 를 사용하시면 됩니다.