Package com. smile. jdo. test;
Import java. io. StringWriter;
Import java. util. ArrayList;
Import java. util. List;
Import org. apache. velocity. Template;
Import org. apache. velocity. VelocityContext;
Import org. apache. velocity. app. VelocityEngine;
Public class VMTest {
/**
* @ Param args
* @ Throws Exception
*/
Public static void main (String [] args) throws Exception {
VelocityEngine engine = new VelocityEngine ();
Engine. init ();
Template tm = engine. getTemplate ("vmhello. vm ");
VelocityContext context = new VelocityContext ();
// Data
List <String> list = new ArrayList <String> ();
List. add ("test1 ");
List. add ("pande ");
List. add ("school ");
Context. put ("list", list );
StringWriter writer = new StringWriter ();
Tm. merge (context, writer );
System. out. println (writer. toString ());
}
}
<Html>
<Body>
# Foreach ($ business in $ list)
$ Business
# End
</Body>
</Html>