velocity

来源:互联网 发布:js中给文本框赋值 编辑:程序博客网 时间:2024/05/16 14:56
public class Main {

/**
* @param args
*/
public static void main(String[] args) {
try {
String templateFile = "org/yzj/exmaple.vm";
Velocity.init("org/yzj/velocity.properties");
VelocityContext context = new VelocityContext();
List<String> list = new ArrayList<String>();
list.add("test 1");
list.add("test 2");
list.add("test 3");
context.put("list", list);
Template template = Velocity.getTemplate(templateFile);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
if(template != null)
template.merge(context, writer);
writer.flush();
writer.close();
}catch (Exception e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}

}





0 0
原创粉丝点击