속도의 네 번째 응용예---Traversing Map collection
//2 Create a Context object VelocityContext context = newVelocityContext(); //3 Add you data objects to this context Map<String,String> map = newHashMap<String,String>(); map.put("key1","value1"); map.put("key2","value2"); map.put("key3","value3"); map.put("key4","value4"); context.put("map", map); //4 Choose a template Template template =Velocity.getTemplate("map.vm"); //5 Merge the template and you data toproduce the output StringWriter sw = new StringWriter(); template.merge(context, sw); sw.flush(); System.out.println(sw.toString());
Template
#foreach($keyin $map.keySet()) $key:$map.get($key) #end ========
그렇습니다 더 많은 관련 내용은 PHP 중국어 홈페이지(m.sbmmt.com)를 참고해주세요!