本教程展示了在 Java 告工具中运行 Web 查看器的基础知识。例如,在 页上显示带有仪表板的 告。
本教程展示了在 Java 告工具中运行 Web 查看器的基础知识。例如,在 页上显示带有仪表板的 告。
首先,我们需要创建动态 Web 项目。

接下来将 Stimulsoft Java Lib 添加到项目中。

也可以转换为 Maven 项目并配置“pom.xml”文件以使用来自Maven 的库:
4.0.0webviewerwebviewer0.0.1-SNAPSHOTwarsrcmaven-compiler-plugin3.5.11.61.6com.stimulsoftstimulsoft-reports-libs2017.1.1
接下来,我们需要在“WebContent/WEB-INF”文件夹中创建“web.xml”文件。在这里,我们配置StimulsoftResource检索 *.js 和图像文件等内容的servlet,以及StiWebViewerActionServlet与 java web 查看器一起操作的servlet :
<ml version="1.0" encoding="UTF-8"gt;<web-app xmlns_xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:web="http://java.sun.com/xml/ns/javaee/webapp_2_5.xsd"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID" version="2.5"><display-name>stimulsoft_webviewer</display-name><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list><servlet><servlet-name>StimulsoftResource</servlet-name><servlet-class>com.stimulsoft.web.servlet.StiWebResourceServlet</servlet-class></servlet><servlet-mapping><servlet-name>StimulsoftResource</servlet-name><url-pattern>/stimulsoft_web_resource/*</url-pattern></servlet-mapping><servlet><servlet-name>StimulsoftAction</servlet-name><servlet-class>com.stimulsoft.webviewer.servlet.StiWebViewerActionServlet</servlet-class></servlet><servlet-mapping><servlet-name>StimulsoftAction</servlet-name><url-pattern>/stimulsoft_webviewer_action</url-pattern></servlet-mapping></web-app>
在下一步中,我们需要在“WebContent”文件夹中创建“index.jsp”页面。在这里,我们加载“Dashboards.mrt” 告模板文件并呈现 告。我们也可以配置 络查看器,例如将背景颜色设置为灰色。最后,将 web 查看器标签放入 jsp 页面:
<%@page import=";com.stimulsoft.base.drawing.StiColorEnum"%><%@page import=";com.stimulsoft.base.drawing.StiColor"%><%@page import=";com.stimulsoft.webviewer.StiWebViewerOptions"%><%@page import=";com.stimulsoft.webviewer.StiWebViewer"%><%@page import=";java.io.File"%><%@page import=";com.stimulsoft.report.StiSerializeManager"%><%@page import=";com.stimulsoft.report.StiReport"%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ taglib uri="http://stimulsoft.com/webviewer" prefix="stiwebviewer"%><!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=UTF-8"><title>Stimulsoft Reports for Java</title></head><body><%StiReport report = StiSerializeManager.deserializeReport(new File(request.getSession().getServletContext().getRealPath("/reports/Dashboards.mrt")));report.render();StiWebViewerOptions options = new StiWebViewerOptions();options.getAppearance().setBackgroundColor(StiColorEnum.Gray.color());pageContext.setAttribute("report", report);pageContext.setAttribute("options", options);%><stiwebviewer:webviewer report="${report}" options="${options}" /></body></html>
现在您可以将项目部署到 Tomcat 并运行它。

在下面的屏幕截图中,可以看到示例代码的结果:

Aspose、E-iceblue、FastReport、Stimulsoft等文档/ 表图表类开发工具享超低折扣,如有需要可直接联系在线客服。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!