The third application example of velocity-sample code for traversing a set array can be found below
The third application example of velocity -- traversing a set/array
// 2. create a Context objectVelocityContext context = newVelocityContext (); // 3.Add your data objects to this contextcontext. put ("list", Arrays. asList ("first", "second", "third", "fourth"); // 4. choose a templateTemplate template = Velocity. getTemplate ("list. vm "); // 5. merge the template and your data toproduce the outputStringWriter sw = new StringWriter (); template. merge (context, sw); sw. flush (); System. out. println (sw. toString ());
Template
# Foreach ($ elementin $ list) $ element # end ================================#foreach ($ ein $ list) $ e # end
The above is the third application example of velocity-traversing the content of the set/array. For more information, see PHP Chinese network (www.php1.cn )!