解决ReportNG中文乱码

  1. 下载ReportNg源码
git clone  https://github.com/dwdyer/reportng.git
  1. 修改AbstractReporter.java(该文件的所在目录为xxx\reportng\reportng\src\java\main\org\uncommons\reportng
    protected void generateFile(File file,
                                String templateName,
                                VelocityContext context) throws Exception
    {
        // Writer writer = new BufferedWriter(new FileWriter(file));
        OutputStream out = new FileOutputStream(file);
        Writer writer = new BufferedWriter(new OutputStreamWriter(out, "utf-8"));
        try
        {
            Velocity.mergeTemplate(classpathPrefix + templateName,
                                   ENCODING,
                                   context,
                                   writer);
            writer.flush();
        }
        finally
        {
            writer.close();
        }
    }

3.编译源码

cd reportng # 进入目录xxx\reportng\reportng
ant # 若无ant,则需搭建

参考:
http://www.it610.com/article/3626590.htm

你可能感兴趣的:(解决ReportNG中文乱码)