velocity第三個應用範例--遍歷集合/陣列
//2.Create a Context object VelocityContext context = newVelocityContext(); //3.Add your data objects to this context context.put("list",Arrays.asList("第一个","第二个","第三个","第四个")); //4.Choose a template Template template =Velocity.getTemplate("list.vm"); //5.Merge the template and your data toproduce the output StringWriter sw = new StringWriter(); template.merge(context, sw); sw.flush(); System.out.println(sw.toString());
範本
#foreach($elementin $list) $element #end ====================== #foreach($ein $list) $e #end
以上就是velocity第三個應用範例--遍歷集合/陣列的內容,更多相關內容請關注PHP中文網(www .php.cn)!