今天发现linux下freemarker发布出来的文件有乱码,整了半天总算搞定。。。。
先发一下参考资料:http://www.ntsky.com/tech/java/opensource/template/2007-10-20/59e034abc198936c.html
cfg = new Configuration();
cfg.setClassForTemplateLoading(TEST.class, "/templates/");
cfg.setEncoding(Locale.CHINA, "GBK");
Template t = cfg.getTemplate("abc.ftl", Locale.CHINA);
new PrintWriter(f, "GBK");
备忘一下。。。。
本文介绍了解决Linux环境下使用Freemarker模板引擎发布文件时出现乱码的方法。通过设置正确的字符编码(如GBK),确保从模板生成的内容能够正确显示。
1125

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



