[英]How to run BIRT reports in a java application?
我通過BIRT在eclipse上設計了報告,可以從“運行”按鈕運行它,如何將其運行為Java代碼?
首先,需要完成配置部分。 將運行時的web-inf\\lib
目錄中的所有jar都包含到您自己的webapp\\web-inf\\lib
目錄中。
然后是您的web.xml中servlet的配置部分,如下所示。
<servlet>
<servlet-name>EngineServlet</servlet-name>
<servlet-class>org.eclipse.birt.report.servlet.BirtEngineServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>EngineServlet</servlet-name>
<url-pattern>/output</url-pattern>
</servlet-mapping>
查看器標簽庫定義:
<jsp-config>
<taglib>
<taglib-uri>/birt.tld</taglib-uri>
<taglib-location>/WEB-INF/tlds/birt.tld</taglib-location>
</taglib>
</jsp-config>
web.xml中可以包含其他設置,用於控制Web查看器的行為。 如下所示:
BIRT_VIEWER_LOCALE:This setting sets the default locale for the Web Viewer.
BIRT_VIEWER_MAX_ROWS: Specifies the maximum number of rows to retrieve from a dataset.
BIRT_RESOURCE_PATH: This setting specifies the resource path used by report engine. The resource path is used to search for libraries, images, and properties files used by a report. If this setting is left blank, resources will be searched for in the same directory as the report.
其他可以從BIRT門戶中學到。 以下是JSP頁面中的示例:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/birt.tld" prefix="birt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<birt:viewer id="birtViewer" reportDesign="myReport.rptdesign"
pattern="frameset"
height="450"
width="700"
format="html">
</birt:viewer>
</body>
</html>
在Web應用程序中為您的報告提供一個菜單,您的報告就可以運行了。 :-)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.