如:%PDF-1.4 %忏嫌 3 0 obj <> stream x溑? ?帻~艒u0鎇?Tp詎?? ]J@緱AB?聟魍馠蹳^€@N'?-県a?(h??X+藮炨l紫h嘎兀?$}第?s?媇丕J3錚+?:&M柙辣rM薶账膬夨9v?鎯?|?Q縄鰶扅:曜蓗=抇E?侬F蛩╛&燑w?? endstream endobj 1 0 obj <> >> /MediaBox [0 0 595 842] >> endobj 6 0 obj <> stream x溑? ?帻~艒u0骝e?Tp詎???%?撙J?!侾聟鱉xn?亹?g??,謩浞瞃y冋嘎
请各位高手帮帮忙解决,谢谢!
pdf.jsp源文件如下:
<%@ page contentType="text/html; charset=GBK" import="datasource.*,dori.jasper.engine.*,java.util.*,java.io.*" %>
<%
File reportFile = new File(application.getRealPath("/report/test_report_4.jasper"));
Map parameters = new HashMap();
parameters.put("ReportTitle", "Address Report");
parameters.put("BaseDir", reportFile.getParentFile());
byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),parameters,new WebappDataSource());
response.setContentType("application/pdf");
//response.setContentType("application/x-msdownload");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
System.out.println("######" + bytes.length);
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
%>
不知要怎么修改才能让显示出来的结果不是乱码?谢谢!
2 个解决方案
#1
charset=gb2312
#2
@ page contentType="text/html; charset=GBK"
去掉这一句试试
去掉这一句试试
#1
charset=gb2312
#2
@ page contentType="text/html; charset=GBK"
去掉这一句试试
去掉这一句试试