ParamUtil pu = new ParamUtil(request);
String content = pu.getString("Content");
Properties prop = new Properties();
prop.put("file.resource.loader.path", "E:/workspace/popln/dist/webapp/WEB-INF/templates/");//配置模版目录
prop.put("input.encoding", "utf-8");//输入编码
prop.put("output.encoding", "utf-8");//输出编码
Velocity.init(prop);//初始化
/* next, get the Template */
Template t = Velocity.getTemplate("comment.vm");
/* create a context and add data */
VelocityContext context = new VelocityContext();
context.put("comment", "DingDangXiaoMa");
context.put("site", "http://www.sun.com");
/* now render the template into a StringWriter */
StringWriter writer = new StringWriter();
t.merge(context, writer);
String comment = writer.toString();
String content = pu.getString("Content");
Properties prop = new Properties();
prop.put("file.resource.loader.path", "E:/workspace/popln/dist/webapp/WEB-INF/templates/");//配置模版目录
prop.put("input.encoding", "utf-8");//输入编码
prop.put("output.encoding", "utf-8");//输出编码
Velocity.init(prop);//初始化
/* next, get the Template */
Template t = Velocity.getTemplate("comment.vm");
/* create a context and add data */
VelocityContext context = new VelocityContext();
context.put("comment", "DingDangXiaoMa");
context.put("site", "http://www.sun.com");
/* now render the template into a StringWriter */
StringWriter writer = new StringWriter();
t.merge(context, writer);
String comment = writer.toString();
outPrintStream(comment,response);
摆弄了近三个小时。这个才能跑