Velocity.init();
VelocityContext context = new VelocityContext();
context.put("name", "yy");
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
Template template = Velocity.getTemplate("VelocityTest1.vm");
template.merge(context, writer);
writer.flush();
writer.close();
把System.out换成文件输出流,就生成html了。