Configuration cfg = new Configuration();
cfg.setDefaultEncoding("UTF-8");
......
Template template = cfg.getTemplate(templateFileName);
template.setEncoding("UTF-8");
creatDirs(buildPath.getFilename(),htmlFilePath);
File htmlFile = new File(buildPath + htmlFilePath + htmlFileName);
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFile),"UTF-8"));
template.process(propMap,out);
out.flush();
本文介绍使用Freemarker进行模板渲染的过程,包括配置环境、设置字符编码为UTF-8、加载模板文件、创建目录、生成HTML文件及将数据模型注入模板进行渲染。
1177

被折叠的 条评论
为什么被折叠?



