81,094
社区成员
发帖
与我相关
我的任务
分享
String proPath = this.getClass().getResource("/").getPath();
System.out.println(proPath+"com/wy/template");
/* 在整个应用的生命周期中,这个工作你应该只做一次。 */
/* 创建和调整配置。 */
Configuration cfg = new Configuration();
cfg.setDirectoryForTemplateLoading(
new File(proPath+"com/wy/template"));
cfg.setObjectWrapper(new DefaultObjectWrapper());
/* 在整个应用的生命周期中,这个工作你可以执行多次 */
/* 获取或创建模板*/
Template temp = cfg.getTemplate("pointShow.ftl");
/* 创建数据模型 */
Map root = new HashMap();
root.put("points", points);
/* 将模板和数据模型合并 */
Writer out = new OutputStreamWriter(System.out);
temp.process(root, out);
out.flush();
//this.out="<p>ceshi</p>";