现有的maven工程,集成birt(及birt的参数配置详解)

简介: 现有的maven工程,集成birt(及birt的参数配置详解)从官网下载新的birt-runtime下载地址为:http://download.eclipse.org/birt/downloads/解压zip格式文件后如图:配置目录结构将上图中WebViewerExample中的文件,按如下图进...

现有的maven工程,集成birt(及birt的参数配置详解)
从官网下载新的birt-runtime
下载地址为:http://download.eclipse.org/birt/downloads/
解压zip格式文件后如图:

配置目录结构
将上图中WebViewerExample中的文件,按如下图进行目录结构的配置:

根目录下新建reportFiles文件夹(放报表文件);
webcontent文件夹直接从WebViewerExample里拿;
WEB-INF下的lib和tlds文件夹直接从WebViewerExample里拿;
在WEB-INF下新建report-engine文件夹,在eport-engine文件夹下新建documents images logs scriptlib四个文件夹;
jrun.web.xml server-config.wsdd viewer.properties 三个文件直接从WebViewerExample里拿;
将WebViewerExample里web.xml里的内容拷到你工程里的web.xml。
web.xml的代码片

<context-param>
    <param-name>BIRT_VIEWER_LOCALE</param-name>
    <param-value>en-US</param-value>
</context-param>

<!-- Default timezone setting. Examples: "Europe/Paris", "GMT+1". Defaults 
    to the container's timezone. -->
<context-param>
    <param-name>BIRT_VIEWER_TIMEZONE</param-name>
    <param-value></param-value>
</context-param>

<!-- Report resources directory for preview. Defaults to ${birt home} -->
<context-param>
    <param-name>BIRT_VIEWER_WORKING_FOLDER</param-name>
    <param-value>reportFiles</param-value>
</context-param>

<!-- Temporary document files directory. Defaults to ${birt home}/documents -->
<context-param>
    <param-name>BIRT_VIEWER_DOCUMENT_FOLDER</param-name>
    <param-value>WEB-INF/report-engine/documents</param-value>
</context-param>

<!-- Flag whether the report resources can only be accessed under the working 
    folder. Defaults to true -->
<context-param>
    <param-name>WORKING_FOLDER_ACCESS_ONLY</param-name>
    <param-value>true</param-value>
</context-param>

<!-- Settings for how to deal with the url report path. e.g. "http://host/repo/test.rptdesign". 
    Following values are supported: <all> - All paths. <domain> - Only the paths 
    with host matches current domain. Note the comparison is literal, "127.0.0.1" 
    and "localhost" are considered as different hosts. <none> - URL paths are 
    not supported. Defaults to "domain". -->
<context-param>
    <param-name>URL_REPORT_PATH_POLICY</param-name>
    <param-value>domain</param-value>
</context-param>

<!-- Temporary image/chart directory. Defaults to ${birt home}/report/images -->
<context-param>
    <param-name>BIRT_VIEWER_IMAGE_DIR</param-name>
    <param-value>WEB-INF/report-engine/images</param-value>
</context-param>

<!-- Engine log directory. Defaults to ${birt home}/logs -->
<context-param>
    <param-name>BIRT_VIEWER_LOG_DIR</param-name>
    <param-value>WEB-INF/report-engine/logs</param-value>
</context-param>

<!-- Report engine log level -->
<context-param>
    <param-name>BIRT_VIEWER_LOG_LEVEL</param-name>
    <param-value>WARNING</param-value>
</context-param>

<!-- Directory where to store all the birt report script libraries (JARs). 
    Defaults to ${birt home}/scriptlib -->
<context-param>
    <param-name>BIRT_VIEWER_SCRIPTLIB_DIR</param-name>
    <param-value>WEB-INF/report-engine/scriptlib</param-value>
</context-param>

<!-- Resource location directory. Defaults to ${birt home} -->
<context-param>
    <param-name>BIRT_RESOURCE_PATH</param-name>
    <param-value></param-value>
</context-param>

<!-- Preview report rows limit. An empty value means no limit. -->
<context-param>
    <param-name>BIRT_VIEWER_MAX_ROWS</param-name>
    <param-value></param-value>
</context-param>

<!-- Max cube fetch levels limit for report preview (Only used when previewing 
    a report design file using the preview pattern) -->
<context-param>
    <param-name>BIRT_VIEWER_MAX_CUBE_ROWLEVELS</param-name>
    <param-value></param-value>
</context-param>
<context-param>
    <param-name>BIRT_VIEWER_MAX_CUBE_COLUMNLEVELS</param-name>
    <param-value></param-value>
</context-param>

<!-- Memory size in MB for creating a cube. -->
<context-param>
    <param-name>BIRT_VIEWER_CUBE_MEMORY_SIZE</param-name>
    <param-value></param-value>
</context-param>

<!-- Defines the BIRT viewer configuration file -->
<context-param>
    <param-name>BIRT_VIEWER_CONFIG_FILE</param-name>
    <param-value>WEB-INF/viewer.properties</param-value>
</context-param>

<!-- Flag whether to allow server-side printing. Possible values are "ON" 
    and "OFF". Defaults to "ON". -->
<context-param>
    <param-name>BIRT_VIEWER_PRINT_SERVERSIDE</param-name>
    <param-value>ON</param-value>
</context-param>

<!-- Flag whether to force browser-optimized HTML output. Defaults to true -->
<context-param>
    <param-name>HTML_ENABLE_AGENTSTYLE_ENGINE</param-name>
    <param-value>true</param-value>
</context-param>

<!-- Filename generator class/factory to use for the exported reports. -->
<context-param>
    <param-name>BIRT_FILENAME_GENERATOR_CLASS</param-name>
    <param-value>org.eclipse.birt.report.utility.filename.DefaultFilenameGenerator</param-value>
</context-param>
<!-- Viewer Servlet Context Listener -->
<listener>
    <listener-class>org.eclipse.birt.report.listener.ViewerServletContextListener</listener-class>
</listener>

<!-- Viewer HttpSession Listener -->
<listener>
    <listener-class>org.eclipse.birt.report.listener.ViewerHttpSessionListener</listener-class>
</listener>
<!-- Viewer Filter used to set the request character encoding to UTF-8. -->
<filter>
    <filter-name>ViewerFilter</filter-name>
    <filter-class>org.eclipse.birt.report.filter.ViewerFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>ViewerFilter</filter-name>
    <servlet-name>ViewerServlet</servlet-name>
</filter-mapping>
<filter-mapping>
    <filter-name>ViewerFilter</filter-name>
    <servlet-name>EngineServlet</servlet-name>
</filter-mapping>
<!-- Viewer Servlet, Supports SOAP -->
<servlet>
    <servlet-name>ViewerServlet</servlet-name>
    <servlet-class>org.eclipse.birt.report.servlet.ViewerServlet</servlet-class>
</servlet>
<!-- Engine Servlet -->
<servlet>
    <servlet-name>EngineServlet</servlet-name>
    <servlet-class>org.eclipse.birt.report.servlet.BirtEngineServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>ViewerServlet</servlet-name>
    <url-pattern>/frameset</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>ViewerServlet</servlet-name>
    <url-pattern>/run</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>EngineServlet</servlet-name>
    <url-pattern>/preview</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>EngineServlet</servlet-name>
    <url-pattern>/download</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>EngineServlet</servlet-name>
    <url-pattern>/parameter</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>EngineServlet</servlet-name>
    <url-pattern>/document</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>EngineServlet</servlet-name>
    <url-pattern>/output</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>EngineServlet</servlet-name>
    <url-pattern>/extract</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>

运行
访问连接:http://localhost:8080/report/preview?__report=test.rptdesign
访问后如图,那么恭喜你,成功了:

birt参数配置

  1. Servlet模式说明
    查看BIRT Viewer自带的web.xml文件,可以看到有以下几个pattern:

frameset ---- 采用Ajax框架,可以显示工具条,导航条和TOC面板,实现复杂的操作,如分页处理,导出数据,导出报表,打印等等。该模式下会自动生成report document文件(预览report design文件)到特定的目录(用户可以用参数指定,也可以定义在web.xml里)。采用Ajax,速度较慢。

run ---- 也采用Ajax框架,但不实现frameset的复杂功能,不会生成临时的report document文件(预览report design文件),也不支持分页,这个主要是应用在BIRT Designer里的preview tab里,可以支持cancel操作,其它不怎么常用。采用Ajax,速度较慢。

preview — 没有用到Ajax框架,直接调用底层Engine API对报表进行render,把生成的报表内容直接输出到浏览器。这种模式和run模式调用的是相同的Engine API,唯一区别在于run采用Ajax获取报表内容,而preview直接输出到浏览器。如果要支持分页,用户需要在URL上定义__page和 __pagerange参数,这两个参数也会在后面详细说明。需要特别说明的是,在这几种预览模式中,preview的速度是最快的。

document — 该模式主要是为了从report design文件生成report document文件。用户可以在URL上提定document文件生成存放的路径(存放在server端),如果未指定,会直接生成 rptdocument发送到客户端浏览器,用户可以下载到客户端。

output — 该模式类似于frameset,会自动生成report document文件(预览report design文件),区别在于output不采用Ajax,而是将生成的报表内容直接输出到浏览器。

parameter — 该模式主要用于生成一个参数对话框,一般用户不常用,用户可以直接通过提供的JSP Tag–parameterPage去实现参数对话框,不需要直接调用。

download — 用于导出报表数据为CSV格式,当你使用frameset工具条里的导出数据功能时,会用到这个模式。

  1. web.xml里的参数设置
    web.xml文件里有许多参数,用户应该根据自已的需求出发对这些参数有一个深入的了解。下面我会对这些参数一一做以说明。

[BIRT_VIEWER_LOCALE]
设置默认的Locale信息,暂时没有太大意义。因为Locale的信息,首先以URL上定义的__locale为准,如果没有定义,会找到当前浏览器的Locale信息,最后才会用到这里定义的信息。

[BIRT_VIEWER_WORKING_FOLDER]
设置BIRT Viewer的工作目录。用户可以把report design或是report document文件存放在这个目录下,这样就可以在URL上采用相对路径去预览这些报表文件了。默认是当前根目录。
当前支持三种形式:
相对路径 — 这个相对当前的WEB应用的context root.
绝对路径
JAVA系统变量 — 可以在启动服务器时,定义JVM的系统变量,如java –Dmyworkingfolder=D:/reports。这样就可以在web.xml中用${myworkingfolder}进行引用了。

[BIRT_VIEWER_DOCUMENT_FOLDER]
设置生成的document文件的存放路径。默认是documents目录。路径设置同上。

[WORKING_FOLDER_ACCESS_ONLY]
简单的报表访问限制控制实现,如果设为true,哪就只能预览存放在工作目录下的报表文件。默认值是false。

[BIRT_VIEWER_IMAGE_DIR]
设置生成的临时图片的存放路径。默认是report/images目录。路径设置同工作目录设置。

[BIRT_VIEWER_LOG_DIR]
设置生成的日志文件存放路径。默认是logs目录。路径设置同工作目录设置。

[BIRT_VIEWER_LOG_LEVEL]
设置日志的level,可选的值有:ALL|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST|OFF。级别由高到低。

[BIRT_VIEWER_SCRIPTLIB_DIR]
设置用户script lib文件的存放目录( 在报表中用到的Java Event Handler Class )。默认值是scriptlib。路径设置同工作目录设置。

[BIRT_RESOURCE_PATH]
设置用户资源存放路径,这些资源包括library文件,image文件等。默认是当前根目录。路径设置同工作目录设置。

[BIRT_VIEWER_MAX_ROWS]
设置获取dataset的最大记录数。主要应用于设计报表的时候,预览报表如果记录数太多,会花费很多的时间,也可能会引起out of memory问题。默认是不限制。

[BIRT_VIEWER_MAX_CUBE_LEVELS]
设置CUBE查询的最大级数。和前面的参数作用类似。默认是不限制。

[BIRT_VIEWER_CUBE_MEMORY_SIZE]
设置在生成CUBE时,可以写在memory中的最大值,单位是MB。可以提高效率,写在内存会比直接写在硬盘快很多。但同时也要注意内存占用的问题。

[BIRT_OVERWRITE_DOCUMENT]
该参数主要用于frameset/output模式,它们会生成临时的document文件上。如果设为true,则每次刷新页面时,都会重新去生成document文件,如果为false,则不会重新生成,只会用原来的document文件去生成报表内容。

[BIRT_VIEWER_CONFIG_FILE]
定义properties文件的路径,不可以修改。

[BIRT_VIEWER_PRINT_SERVERSIDE]
在frameset工具条上,提供有后台服务器打印的功能,该参数可以设置是打开还是关闭后台打印的功能。默认是打开。可选值为: ON 和 OFF。

[HTML_ENABLE_AGENTSTYLE_ENGINE]
这个参数是会传递给Engine的,主要用于一些CSS的兼容性方面的问题。默认值是true。

  1. viewer.properties参数设置
    viewer.properties文件主要是定义一些扩展的参数。

configurable variable for JSP base href. Please uncomment the below line.

base_url=http://127.0.0.1:8080

该设置主要应用于代理服务器的情况下,在使用代理服务器后,从request里获取的URI并非真正的URI,需要在这里定义。

[EXTENSION SETTING]

viewer.extension.html=html
viewer.extension.pdf=pdf
viewer.extension.postscript=ps
viewer.extension.doc=doc
viewer.extension.xls=xls
viewer.extension.ppt=ppt
定义输出的报表文件的后缀名,和format相关联。

[OUTPUT FORMAT LABEL NAME]

viewer.label.html=HTML
viewer.label.pdf=PDF
viewer.label.postscript=PostScript
viewer.label.doc=Word
viewer.label.xls=Excel
viewer.label.ppt=PowerPoint
定义导出报表对话框里的报表格式列表,和format相关联,这样名字会更有意义。

[CSV SEPARATOR]

viewer.sep.0=,
viewer.sep.1=;
viewer.sep.2=:
viewer.sep.3=|
viewer.sep.4=t
支持多种CSV分隔符,用户也可以增加新的分隔符(只支持char,而不是string)。但同时需要修改JSP文件和Messages.properties文件。

[VIEWING SESSION CONFIGURATION]

The BIRT viewing session is a sub-session of the HTTP session.

An HTTP session can have multiple BIRT viewing sessions.

Each time a new viewer is opened, a new viewing session is created.

The following parameters are used to configure the viewing session

management.

If the matching HTTP session expires, all the viewing sessions

attached to it will expire as well.

Timeout value in seconds after which a viewing session will expire.

The value 0 means that a session will never expire, and the cached files

will never be cleant unless the belonging HTTP session expires.

viewer.session.timeout=1800

Defines a session count threshold after which the cleanup process

will try to clean up expired sessions.

viewer.session.minimumThreshold=500

Load factor to recalculate the minimum threshold value based on the remaining

session count after cleanup.

viewer.session.loadFactor=0.75

Maximum number of simultaneous viewing sessions that can be open at the

same time, to prevent cache overflowing through multiple requests.

A value of 0 means no limit.

viewer.session.maximumSessionCount=0

Behavior that must be used once the maximum session count is reached

(if different than 0):

- A value of 0 will use the “Discard new session” policy that will show

an error message for all the newer sessions.

- A value of 1 will use the “Discard the oldest session” policy that will

try to discard the oldest session, even if it has not expired yet.

Note that “busy” sessions (for example downloading results) won’t be

cleant by this mechanism.

viewer.session.maximumSessionCountPolicy=1

[LOGGERS]

“logger.”+class=level

if no level is specified or the text “DEFAULT”,

then the default level from the web.xml will be used

logger.org.eclipse.datatools.connectivity.oda=DEFAULT

logger.org.eclipse.datatools.enablement.oda=DEFAULT

作者:Fly_maxiaotiao
来源:CSDN
原文:https://blog.csdn.net/Fly_maxiaotiao/article/details/94734771
版权声明:本文为博主原创文章,转载请附上博文链接!

相关文章
|
2月前
|
Java Apache Maven
【Maven从入门到如土】Maven 核心程序解压和配置
【Maven从入门到如土】Maven 核心程序解压和配置
61 0
|
2月前
|
Java 程序员 API
Springboot-swagger配置(idea社区版2023.1.4+apache-maven-3.9.3-bin)
Springboot-swagger配置(idea社区版2023.1.4+apache-maven-3.9.3-bin)
59 1
|
2月前
|
前端开发 Java 数据库连接
Springboot-MyBatis配置-配置端口号与服务路径(idea社区版2023.1.4+apache-maven-3.9.3-bin)
Springboot-MyBatis配置-配置端口号与服务路径(idea社区版2023.1.4+apache-maven-3.9.3-bin)
33 0
|
1月前
|
Java Maven
Maven【5】在IDEA环境中配置和使用Maven
Maven【5】在IDEA环境中配置和使用Maven
65 1
|
2月前
|
Java Maven
【Maven】下载配置maven以及IDEA配置maven详情
【Maven】下载配置maven以及IDEA配置maven详情
131 0
|
3月前
|
Java Maven
Maven配置仓储和配置国内镜像
Maven配置仓储和配置国内镜像
406 0
|
1天前
|
Java Maven
【IDEA】常用快捷键和自定义方法补全(附如何设置IDEA全局配置,如Maven)
【IDEA】常用快捷键和自定义方法补全(附如何设置IDEA全局配置,如Maven)
6 0
|
1月前
|
Java Maven
Maven【2】( Web 工程依赖 Java 工程)(命令行操作)
Maven【2】( Web 工程依赖 Java 工程)(命令行操作)
20 0
|
1月前
|
Devops 开发工具 数据安全/隐私保护
Docker Swarm总结+CI/CD Devops、gitlab、sonarqube以及harbor的安装集成配置(3/5)
Docker Swarm总结+CI/CD Devops、gitlab、sonarqube以及harbor的安装集成配置(3/5)
55 0
|
2月前
|
Java 应用服务中间件 Maven
【Maven从入门到如土】创建 Maven 版的 Web 工程
【Maven从入门到如土】创建 Maven 版的 Web 工程
37 0

热门文章

最新文章

推荐镜像

更多