Java

本类阅读TOP10

·使用MyEclipse开发Struts框架的Hello World!(录像1)
·hibernate配置笔记
·AOP编程入门--Java篇
·linux下Tomcat 5.0.20 与 Apache 2 安装/集成/配置
·在win2003下整合了整合Tomcat5.5+ apache_2.0.53+ mod_jk_2.0.47.dll
·构建Linux下IDE环境--Eclipse篇
·Jsp 连接 mySQL、Oracle 数据库备忘(Windows平台)
·ASP、JSP、PHP 三种技术比较
·Tomcat5.5.9的安装配置
·AWT GUI 设计笔记(二)

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
今天搞了 ireport跟jasperreport

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

由于中文的问题,所以还需要下载:itext-1.02b.jar和iTextAsian.jar包 

在properties里需修改font为某种系统内的中文字体,PDF font name选择STSong_Light,选中PDF Embeded PDF Encoding为UniGB-UCS2-H(Chinese simplified)。并且将iTextAsian.jar加入到ireport的lib文件夹下,这样通过ireport产生的pdf文件就支持中文了。

记得把itext-1.02b.jar跟iTextAsian.jar放到JBOSS的LIB下,不然找不到。

<%@ page contentType="text/html;charset=GB2312" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="net.sf.jasperreports.engine.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<html>
<head>
  <title>abc</title>
</head>
<body>
<%
 System.out.println("chenggong");

     File reportFile = new File(application.getRealPath("aall.jasper"));
 System.out.println("chenggong");

       Map parameters = new HashMap();

       parameters.put("name", "p");

       

       Connection conn=null;
      try
      {
          Class.forName("org.gjt.mm.mysql.Driver");
          conn=DriverManager.getConnection("jdbc:mysql://localhost/music?useUnicode=true&characterEncoding=GB2312","root","c5757078");
           System.out.println("chenggong");

      }
      catch(Exception e)
      {
         System.out.println(e);
      }
       JasperRunManager run=new JasperRunManager();
                            
System.out.println("abc");
       byte[] bytes = run.runReportToPdf(reportFile.getPath(), parameters, conn);      
      System.out.println("abc");
       response.setContentType("application/pdf");

       response.setContentLength(bytes.length);

       ServletOutputStream ouputStream = response.getOutputStream();

       ouputStream.write(bytes, 0, bytes.length);

       ouputStream.flush();

       ouputStream.close();

%>

</body>
</html>




相关文章

相关软件