时间:2021-07-01 10:21:17 帮助过:47人阅读
//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.gxlcms.com)!