下面是生成报表的代码: response.setCharacterEncoding("UTF-8");
JRHtmlExporter htmlExporter = new JRHtmlExporter();
request.getSession().setAttribute (ImageServlet.DEFAULT_JASPER_PRINT_LIST_SESSION_ATTRIBUTE,jasperPrintList);
htmlExporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST,jasperPrintList); htmlExporter.setParameter(JRExporterParameter.OUTPUT_WRITER, printWriter); htmlExporter.setParameter(JRHtmlExporterParameter.CHARACTER_ENCODING, "UTF-8"); htmlExporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"/IPBearNet/ibn/plan/image?image="); htmlExporter.exportReport();
那里错了!中文变成了乱码!!!!
JRHtmlExporter htmlExporter = new JRHtmlExporter();
request.getSession().setAttribute (ImageServlet.DEFAULT_JASPER_PRINT_LIST_SESSION_ATTRIBUTE,jasperPrintList);
htmlExporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST,jasperPrintList); htmlExporter.setParameter(JRExporterParameter.OUTPUT_WRITER, printWriter); htmlExporter.setParameter(JRHtmlExporterParameter.CHARACTER_ENCODING, "UTF-8"); htmlExporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"/IPBearNet/ibn/plan/image?image="); htmlExporter.exportReport();
那里错了!中文变成了乱码!!!!
这句代码必须放在out对象获取之前,否则无效。
我把response.setCharacterEncoding("UTF-8");
放到后面去了 所以没出来