遇到问题2。
在IREPORT中编译好有数据库连接的.JXML执行时,请注意执行方法:EXECUTE(EMPTY DATASOURCE)EXECUTE(WITH ACTIVE CONNECTION) ;
遇到问题2。
把编译好的 UT1.JASPER 文件COPY到 REPORTS文件夹下 在SRC文件下建 UT1.JAVA ,ECLIPSE没能生成.CLASS 文件 , UT1.JAVA保存没有出现错误,且上周同项目下的.JAVA 可以生成.CLASS ?检查项目的ECLIPSE--PROJECT-PROPERTIES FOR JASPER 在 JAVA BUILD PATH -JRE-有两个JASPER (一个是JASPER的全部的.JAR 一个是含有一个.JAR ,这是自己设置的 ,去掉后者 )编译通过
server.xml:
web.xml
4 中文问题
@1 设置classpath:itext-1.3.1.jar(自带) /iTextAsian.jar
下载地址 :http://itext.sourceforge.net/downloads/iTextAsian.jar
@2 Font 创建一个FONT <reportFont name="Arial_Normal" fontName="Arial"pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" /> 其中fontName 在某些时候可以选择('宋体'等常用的格式) 或者设置style
style 设置style的属性 <style pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" />并选中isStyledText (这个相对麻烦些 不过控制好)
@3 在JSP输出时 请加<%@ page contentType="text/html;charset=UTF-8" %> (柱:有人讲不应加,但我加上这句才能正常显示)
5 HTML 输出
在IREPORT中编译好有数据库连接的.JXML执行时,请注意执行方法:EXECUTE(EMPTY DATASOURCE)EXECUTE(WITH ACTIVE CONNECTION) ;
遇到问题2。
把编译好的 UT1.JASPER 文件COPY到 REPORTS文件夹下 在SRC文件下建 UT1.JAVA ,ECLIPSE没能生成.CLASS 文件 , UT1.JAVA保存没有出现错误,且上周同项目下的.JAVA 可以生成.CLASS ?检查项目的ECLIPSE--PROJECT-PROPERTIES FOR JASPER 在 JAVA BUILD PATH -JRE-有两个JASPER (一个是JASPER的全部的.JAR 一个是含有一个.JAR ,这是自己设置的 ,去掉后者 )编译通过
3.建个连接池:注意事项:
把%oracle_home% /lib/classes12.jar copy 到 %tomcat _home%/common/lib下server.xml:
<
Context
path
="/jasper"
reloadable
="true"
docBase
="C:Documents and Settingsworkspacejasper"
debug
="0"
>
< Logger className ="org.apache.catalina.logger.SystemOutLogger" verbosity ="4" timestamp ="true" />
< Resource name ="jdbc/oracledb" auth ="Container" type ="javax.sql.DataSource" />
< ResourceParams name ="jdbc/oracledb" >
< parameter >
< name > factory </ name >
< value > org.apache.commons.dbcp.BasicDataSourceFactory </ value >
</ parameter >
< parameter >
< name > driverClassName </ name >
< value > oracle.jdbc.driver.OracleDriver </ value >
</ parameter >
< parameter >
< name > url </ name >
< value > jdbc:oracle:thin:@127.0.0.1:1521:orcl </ value >
</ parameter >
<!-- SAS Share username and password for dB connections -->
< parameter >
< name > username </ name >
< value > system </ value >
</ parameter >
< parameter >
< name > password </ name >
< value > system </ value >
</ parameter >
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
< parameter >
< name > maxActive </ name >
< value > 100 </ value >
</ parameter >
<!-- Maximum number of idle dB connections to retain in pool.
Set to -1 for no limit. See also the DBCP documentation on this
and the minEvictableIdleTimeMillis configuration parameter.
-->
< parameter >
< name > maxIdle </ name >
< value > 10 </ value >
</ parameter >
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
< parameter >
< name > maxWait </ name >
< value > 1000 </ value >
</ parameter >
</ ResourceParams >
</ Context >
< Logger className ="org.apache.catalina.logger.SystemOutLogger" verbosity ="4" timestamp ="true" />
< Resource name ="jdbc/oracledb" auth ="Container" type ="javax.sql.DataSource" />
< ResourceParams name ="jdbc/oracledb" >
< parameter >
< name > factory </ name >
< value > org.apache.commons.dbcp.BasicDataSourceFactory </ value >
</ parameter >
< parameter >
< name > driverClassName </ name >
< value > oracle.jdbc.driver.OracleDriver </ value >
</ parameter >
< parameter >
< name > url </ name >
< value > jdbc:oracle:thin:@127.0.0.1:1521:orcl </ value >
</ parameter >
<!-- SAS Share username and password for dB connections -->
< parameter >
< name > username </ name >
< value > system </ value >
</ parameter >
< parameter >
< name > password </ name >
< value > system </ value >
</ parameter >
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
< parameter >
< name > maxActive </ name >
< value > 100 </ value >
</ parameter >
<!-- Maximum number of idle dB connections to retain in pool.
Set to -1 for no limit. See also the DBCP documentation on this
and the minEvictableIdleTimeMillis configuration parameter.
-->
< parameter >
< name > maxIdle </ name >
< value > 10 </ value >
</ parameter >
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
< parameter >
< name > maxWait </ name >
< value > 1000 </ value >
</ parameter >
</ ResourceParams >
</ Context >
web.xml
<
resource
-
ref
>
< description > DB Connection </ description >
< res - ref - name > jdbc / oracledb </ res - ref - name >
< res - type > javax.sql.DataSource </ res - type >
< res - auth > Container </ res - auth >
</ resource - ref >
< description > DB Connection </ description >
< res - ref - name > jdbc / oracledb </ res - ref - name >
< res - type > javax.sql.DataSource </ res - type >
< res - auth > Container </ res - auth >
</ resource - ref >
<
resource-ref
>
< description > DB Connection </ description >
< res-ref-name > jdbc/oracledb </ res-ref-name >
< res-type > javax.sql.DataSource </ res-type >
< res-auth > Container </ res-auth >
</ resource-ref >
< description > DB Connection </ description >
< res-ref-name > jdbc/oracledb </ res-ref-name >
< res-type > javax.sql.DataSource </ res-type >
< res-auth > Container </ res-auth >
</ resource-ref >
4 中文问题
@1 设置classpath:itext-1.3.1.jar(自带) /iTextAsian.jar
下载地址 :http://itext.sourceforge.net/downloads/iTextAsian.jar
@2 Font 创建一个FONT <reportFont name="Arial_Normal" fontName="Arial"pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" /> 其中fontName 在某些时候可以选择('宋体'等常用的格式) 或者设置style
style 设置style的属性 <style pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" />并选中isStyledText (这个相对麻烦些 不过控制好)
@3 在JSP输出时 请加<%@ page contentType="text/html;charset=UTF-8" %> (柱:有人讲不应加,但我加上这句才能正常显示)
5 HTML 输出
JasperReport jasperReport
=
(JasperReport)JRLoader.loadObject(reportfile.getPath());
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,conn);
JRHtmlExporter exporter = new JRHtmlExporter();
Map imagesMap = new HashMap();
session.setAttribute( " IMAGES_MAP " , imagesMap);
exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP,imagesMap);
//图的路径
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, " /reports/Untitled_report_4.html_files/ " );
//不用 px ,不然全是未显示的图片 ,直接写成 Boolean .false 提示有问题
boolean a = false ;
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN , a);
exporter.exportReport();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,conn);
JRHtmlExporter exporter = new JRHtmlExporter();
Map imagesMap = new HashMap();
session.setAttribute( " IMAGES_MAP " , imagesMap);
exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP,imagesMap);
//图的路径
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, " /reports/Untitled_report_4.html_files/ " );
//不用 px ,不然全是未显示的图片 ,直接写成 Boolean .false 提示有问题
boolean a = false ;
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN , a);
exporter.exportReport();