Ireport - "Black Cat" problem

zhaozj2021-02-16  104

In these two days, I always took the time to study the "black cat" of this foreign import - IReport 0.5.x, I found that it is not easy to use, especially its information, yesterday, I built it yesterday. One of the simplest reports in the Jrviwer Previwer in Ireport, but I called when I was called in JSP, the report file reads an error, I checked for a long time, I found a half-day information in the online forum, I found it turned out. 0. 5. The version of X has this question. It is the report that the compiled serialization file does not have suffix jasper, you need to modify it, add this suffix to it, and call this compiled * .jasper file in JSP.

The code in JSP is as follows:

<% @ Page ContentType = "Text / HTML; Charset = GBK"%> <% @ Page Import = "Dori.jasper.Engine. *"%> <% @ page import = "DOR.JASPER.ENGINE.UTIL. * "%> <% @ page import =" dori.jasper.Engine.export. * "%> <% @ page import =" java.util. * "%> <% @ page import =" java.io. * " %> <% @ page import = "java.sql. *"%> <% connection conn = null; // below ignore the database connection process // ... try {class.forname ("com.microsoft.jdbc.sqlserver .Sqlserverdriver "); conn = java.sql.driverManager.getConnection (" JDBC: Microsoft: SQLSERVER: // localhost: 1433; DatabaseName = Bookshop "," SA "," 1 ");} catch (sqlexception ex) {EX .printStackTrace ();} catch (ClassNotFoundException ex) {ex.printStackTrace ();} // ...... File reportFile = new File (application.getRealPath ( "/ report / booksjasper.jasper")); Map parameters = new HashMap ( ); //parameters.put ("ADRESS report"); //parameters.put ("Basedir ", reportfile.getParentFile ()); byte [] bytes = jasperrunmanager.RunReportTopdf (ReportFile.GetPath (), Parameters, Conn; Response.setContentType ("Application / PDF"); response.s etContentLength (bytes.length); ServletOutputStream ouputStream = response.getOutputStream (); ouputStream.write (bytes, 0, bytes.length); ouputStream.flush (); ouputStream.close ();%> <% @ page contentType = " TEXT / HTML; Charset = GBK "%> <% @ Page ContentType =" Text / HTML; Charset = GBK "%> <% @ page import =" DORI.JASPER.ENGINE. * "%> <% @ Page Import = "dori.jasper.Engine.UTIL. *"%> <% @ Page Import =

"dori.jasper.Engine.export. *"%> <% @ page import = "java.util. *"%> <% @ page import = "java.io. *"%> <% @ Page Import = " Java.sql. * "%> <% connection conn = NULL; // below ignore the database connection process // ... try {class.forname (" com.microsoft.jdbc.sqlserver.sqlserverdriver); conn = java. sql.DriverManager.getConnection ( "jdbc: microsoft: sqlserver: // localhost: 1433; DatabaseName = bookshop", "sa", "1");} catch (SQLException ex) {ex.printStackTrace ();} catch (ClassNotFoundException EX) {EX.PrintStackTrace ();} // ... File ReportFile = new file (Application.getRealPath ("/ report / booksjasper.jasper"))); map parameters = new hashmap (); //parameters.put (" ReportTitle "," Address Report "); //parameters.put("BaseDir", reportFile.getParentFile ()); byte [] bytes = JasperRunManager.runReportToPdf (reportFile.getPath (), parameters, conn); response.setContentType ( Application / PDF "); response.setContentLength; ServletOutputStream OuputStre AM = response.getOutputStream (); OuputStream.write (bytes, 0, bytes.length); OuputStream.flush (); OuputStream.close ();%> This problem is solved.

But there is one

serious problem

No solution, that is, Chinese problem, although I previewed normal in Jrviwer Previwer in Ireport, but I can't display Chinese in PDF, but why is my PDF unable to display Chinese? ? Font Name in the attribute of the label I chose the "Song" PDF Font Name drop-down box without Chinese options, what should I do. I chose the checkbox of the lowermost PDF Encoding, and I also selected it to be CHINESE Simple. But I still can't display Chinese when previewing in the PDF. Crazy, everyone gives me a look at this setting? If there is a mistake, please give me a message? Thank you!

Related Resources: Ireport-4.5.1 Ireport.zip

转载请注明原文地址:https://www.9cbs.com/read-15165.html

New Post(0)