|
之前项目是用jetty测试, 后来放到tomcat中发现中文乱码问题。
仔细查看了一下, 发现是freemarker生成的文件编码格式不是utf-8.
网上查了一下, 参考
http://blog.csdn.net/it_man/article/details/3808697
首先修改freemarkerUtil代码:
Template template=getTemplate(fname);
template.setEncoding("utf-8");
template.process(root, new PrintWriter(new File(outpath)));
运行之后问题依旧。
看了下链接博客,
改成Template template=getTemplate(fname);
template.setEncoding("utf-8");
//template.process(root, new PrintWriter(new File(outpath)));
Writer out=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outpath)),"utf-8"));
template.process(root, out);
问题解决了。
详细请看链接。
比较奇怪的是之前在myeclipse里用maven+jetty生成的文件都是utf8编码的格式。 |
|
|