我用freeer模板生成的hmtl页面是乱码各位前辈帮我看看是什么问题吧
1,freeer.properties配置
default_encoding=UTF-8
locale=zh_CN2,.ftl模板
也设置了
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">3,程序
/**
* 根据指定的模板生成指定文件
* @param root 数据Map
* @param path 模板存放的路径
* @param templatefileName 模板文件名
* @param outFilePath 输出文件的路径
* @throws Exception
* @author zmw [email protected]
*/
public static void genericFile(Map root,String path,String templatefileName, String outFilePath)throws Exception{
Configuration cfg = new Configuration();
cfg.setEncoding(Locale.getDefault(), "UTF-8");
cfg.setDirectoryForTemplateLoading(new File(path));
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setCacheStorage(new freeer.cache.MruCacheStorage(20,250));
Template temp = cfg.getTemplate(templatefileName);
temp.setEncoding("UTF-8");
Writer writerFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFilePath),"UTF-8"));
temp.process(root,writerFile);
writerFile.flush();
}
生成的html页面是乱码。
1,freeer.properties配置
default_encoding=UTF-8
locale=zh_CN2,.ftl模板
也设置了
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">3,程序
/**
* 根据指定的模板生成指定文件
* @param root 数据Map
* @param path 模板存放的路径
* @param templatefileName 模板文件名
* @param outFilePath 输出文件的路径
* @throws Exception
* @author zmw [email protected]
*/
public static void genericFile(Map root,String path,String templatefileName, String outFilePath)throws Exception{
Configuration cfg = new Configuration();
cfg.setEncoding(Locale.getDefault(), "UTF-8");
cfg.setDirectoryForTemplateLoading(new File(path));
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setCacheStorage(new freeer.cache.MruCacheStorage(20,250));
Template temp = cfg.getTemplate(templatefileName);
temp.setEncoding("UTF-8");
Writer writerFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFilePath),"UTF-8"));
temp.process(root,writerFile);
writerFile.flush();
}
生成的html页面是乱码。
解决方案 »
- FreeMarker 中Expression columns is undefined
- 请问在TOMCAT里怎么配置定期执行一个JSP文件???
- 文件改名失败、异常却无法捕捉。。。
- 在通过链接跳转页面的时候,跟在路径后面的参数值能否为中文?
- 有哪位兄弟姐妹能帮小弟粘份csv出力的代码呀?
- 十分郁闷的问题
- iReport 0.3.2 datasource -->report query为何 没有datasource输入框?
- 请问javascript怎么操作框架frame
- jsp
- Oracle数据库中的中文如何在Jsp正确显示?
- jbuilder2006+jboss中写个简单的jsp,出错:Invocation Error
- struts2如何讲一个word文档保存在oracle中呢?
<jsp-property-group>
<description>
Special property group for JSP Configuration JSP
example.
</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.htm</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>