首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

集成 BIRT 查看器与 Java 和 Java EE Web 应用程序(2)

集成 BIRT 查看器与 Java 和 Java EE Web 应用程序(2)

Maven 和非 Maven 类型的项目的相同步骤
  • 在 web application 件夹下创建以下目录:
    • logs
    • report
    • report/images
    • scriptlib
  • WEB-INF 文件夹下,创建一个 tlds 文件夹。
  • WEB-INF 文件夹下,放入 birt.tld(参见  中的 programfiles.zip)。
  • server-config.wsddviewer.properties 文件(参见  中 programfiles.zip)放在 WEB-INF 文件夹下。
  • webcontent 文件夹(参见  中的 webcontent.zip)放在 web          application 文件夹下。
  • 将您的报告设计文件(.rptdesign 文件)放在 report 文件夹下。
  • 正确创建所有文件夹并将它们放入不同的文件后,WebContent 文件夹将会类似于图 1 中的列表: 图 1. 目录清单
  • 将  中的代码添加到 web.xml 文件中。 清单 3. Web.xml 中的条目            
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    <!-- Report resources directory for preview. Defaults to ${birt home} -->

      <context-param>
        <param-name>BIRT_VIEWER_WORKING_FOLDER</param-name>
        <param-value>report</param-value>
      </context-param>

      <!-- Flag whether the report resources can be accessed only
      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.
      For example, "http://host/repo/test.rptdesign".
           Following values are supported:
           <all> - All paths.
           <domain> - Only the paths with host matches current domain.
           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>

      <!-- 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 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 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 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>

      <!-- For Web module version higher than 2.3 -->
      <!--
      <jsp-config>
        <taglib>
          <taglib-uri>/birt.tld</taglib-uri>
          <taglib-location>/WEB-INF/tlds/birt.tld</taglib-location>
        </taglib>
      </jsp-config>
      -->

    <!-- For Web module version 2.3 -->
      <taglib>
        <taglib-uri>
          /birt.tld
        </taglib-uri>
            <taglib-location>
          /WEB-INF/tlds/birt.tld
        </taglib-location>
      </taglib>




  • 构建并部署应用程序。
  • 使用以下 URL 查看报告:
    • 在 VIRT 查看器中查看报告http://[host]:[port]/[/[context                  name]/frameset?__report=[your report].rptdesign
    • 查看 PDF 或 HTML 格式的完整报告http://[host]:[port]/[context                  name]/run?__report=[report              name].rptdesign&__format=[pdf/html]
附加到文档中的所有文件和文件夹内容(viewservlets.jar、birt.tld、viewer.properties、server-config.wsdd 和        webcontent.zip)都来自 BIRT 运行时 4.2.0 下载文件。在  中找到 webcontent.zip 和        programfiles.zip 文件。
返回列表