皕傑報表在jetty上部署
阿新 • • 發佈:2018-12-19
皕傑報表在jetty伺服器上部署 一、Jetty配置皕傑環境 1.準備工作 開發工具:eclispe、皕傑報表演示例項demoserver、Web伺服器jetty-9.4.12、c3p0jar包、hsql驅動包 2.準備皕傑環境 在eclipse上新建web專案,將皕傑報表演示例項demoserver/webapp/report下的內容複製進來 3.Eclipse配置jetty伺服器 4.Eclipse配置jetty啟動report專案 二、Jetty配置皕傑資料來源 1.在jetty/lib下建立jndi資料夾,c3p0所需jar包(c3p0-0.9.5.2.jar和mchange-commons-java-0.2.11.jar)和hsql驅動包(hsqldb.jar)放到jetty/lib/jndi資料夾下。 2.在eclipse的report專案WEB-INF資料夾下建立jetty-env.xml檔案,配置連線池資訊
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <!-- 應用資料來源 --> <New id="BIOS_DS" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg>BIOS_DS</Arg> <Arg> <New class="com.mchange.v2.c3p0.ComboPooledDataSource"> <Set name="driverClass">org.hsqldb.jdbcDriver</Set> <Set name="jdbcUrl">jdbc:hsqldb:file:D:/data/biosembededdb</Set> <Set name="user">sa</Set> <Set name="password"></Set> </New> </Arg> </New> </Configure>
3.在web.xml裡面加入以下配置
<resource-ref>
<description>My DataSource Reference</description>
<res-ref-name>BIOS_DS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
4.WEB-INF/resources下修改config.xml
<dsConf>
<dataSource>
<Name>BIOS_DS</Name>
<JNDIPrefix>java:comp/env/</JNDIPrefix>
<JNDIName>BIOS_DS</JNDIName>
<DBType>HSQL</DBType>
<DBEncode>gb2312</DBEncode>
<SQLDecode>false</SQLDecode>
<Default>true</Default>
</dataSource>
</dsConf>
5.在eclipse jetty配置勾選jndi支援選項 6.配置成功,訪問一張報表http://localhost:8080/report/ReportEmitter?rpt=Demo/分組報表/1普通分組.brt 注意:如果你的專案是gbk格式的,在jetty/start.ini加上 -Dorg.eclipse.jetty.util.URI.charset=GBK