我用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.   

    在web.xml中增加<jsp-config>
    <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>