1.1 應用場景
使用者希望存取平台時,存取路徑中沒有/webroot/decision。
使用者希望只透過 IP 或者域名存取 Tomcat 工程。
使用者希望存取平台的 URL 能夠變短一些,或者存取範本的地址能夠變短一些。
1.2 功能簡介
通常在 Tomcat 伺服器部署 完成之後,啟動伺服器,使用者需要存取 URL:http://localhost:8080/webroot/decision 方可進入數據決策系統。
有時使用者希望可以直接透過 IP 就能存取數據決策系統。
透過修改埠號並建立虛擬目錄來實現存取 IP(例如:http://localhost)即可直接進入數據決策系統。
注:本文僅介紹如何透過 IP 存取工程,如需透過域名存取,請根據實際情況,將IP與域名綁定,本文不再贅述。
以存取http://localhost為例進行介紹。
2.1 修改埠號
如果沒有其他網路程式佔用埠號 80,可以將 Tomcat 伺服器的埠號設定為 80。
80 埠為預設埠,使用者存取報表頁面時就不需要再加上 Tomcat 伺服器的埠號。
1)開啟%tomcat_home%\conf\server.xml檔案,修改埠號,如下圖所示:

程式碼如下所示:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
2)重啟 Tomcat 伺服器,存取http://localhost/webroot/decision即可進入數據決策系統。
2.2 設定歡迎畫面
每個 Web 伺服器都有預設歡迎畫面,透過修改歡迎畫面,以顯示平台頁面。
在%Tomcat_home%\webapps\webroot目錄下建立 a.jsp檔案,作為 Web 伺服器的預設主頁。
2.2.1 PC 端和 App 端設定介面
檔案下載:a.jsp
「a.jsp」呼叫 iframe 整合平台產品示範介面,程式碼如下所示:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>FineReport報表</title>
<link rel="stylesheet" type="text/css" href="/decision/file?path=/com/fr/web/core/css/leaflet.css&type=plain&parser=plain"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1, maximum-scale=1.0, user-scalable=no">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<iframe id="reportFrame" src="decision" allowfullscreen="true"
name="itemslist" frameborder="0" width="100%" height="100%"></iframe>
</body>
</html>
注:<link rel="stylesheet" type="text/css" href="/decision/file?path=/com/fr/web/core/css/leaflet.css&type=plain&parser=plain"/> 這行程式碼用於解決決策系統中圖表工具欄全螢幕後地圖顯示異常的問題。
重啟 Tomcat 伺服器,存取http://localhost/webroot/a.jsp即可顯示數據決策系統登入頁面。
2.2.2 HTML5 端設定介面
檔案下載:a.jsp
「a.jsp」呼叫 iframe 整合平台產品示範介面,程式碼如下所示:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>FineReport報表</title>
<link rel="stylesheet" type="text/css" href="/decision/file?path=/com/fr/web/core/css/leaflet.css&type=plain&parser=plain"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1, maximum-scale=1.0, user-scalable=no">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<iframe id="reportFrame" src="decision" allowfullscreen="true"
name="itemslist" frameborder="0" width="100%" height="100%"></iframe>
</body>
</html>
注:HTML5 端設定時需要安裝 HTML5 行動端展現插件
2.3 建立虛擬目錄
透過修改配置檔案建虛擬目錄。
2.3.1 調整工程路徑
報表工程 webroot 預設放在%Tomcat_home%\webapps目錄下,啟動伺服器時會載入該工程。建立虛擬目錄後,啟動 Tomcat 伺服器時,透過配置檔案會再次載入 webroot 工程。webroot 工程載入兩次,會出現報錯、伺服器閃退等情況。
因此使用者需要將%Tomcat_home%\webapps目錄下的 webroot 資料夾行動到 Tomcat 部署目錄以外的位置,並且需要與 Tomcat 工程在相同路徑的磁碟下。
本文將%Tomcat_home%\webapps\webroot資料夾行動到E:\webroot路徑。如下圖所示:

注:不是複製 webroot 而是行動,原%Tomcat_home%\webapps下不應有 webroot 檔案。
2.3.2 修改 server.xml 檔案
修改%tomcat_home%\conf\server.xml檔案,在 server.xml 檔案中 host 標籤之間新增上程式碼,如下圖所示:

程式碼如下所示:
<Context path="" docBase="D:\webroot" debug="0" reloadable="false" />
說明:
參數 | 說明 |
---|
path | 虛擬目錄的名稱 如果希望輸入 IP 地址就顯示主頁,則該鍵值留為空 |
docBase | 虛擬目錄的路徑 本文 2.3.1 步驟中設定的 webroot 路徑,本文為E:\webroot |
debug | 0 |
reloadable | false |
2.3.3 修改 web.xml 檔案
先檢查 %tomcat_home%\conf\web.xml 路徑下有無 web.xml 檔案。
如果有 web.xml 檔案,直接編輯檔案,在檔案末尾 </web-app> 標籤之前,新增一段程式碼顯示自訂歡迎畫面 a.jsp,程式碼如下:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>a.jsp</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
如果沒有 web.xml 檔案,需要在webroot\WEB-INF 目錄下建立 web.xml 檔案:web.xml,如下圖所示:

程式碼如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Template WebApp</display-name>
<mime-mapping>
<extension>msi</extension>
<mime-type>application/x-msi</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>a.jsp</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
2.4 效果預覽
2.4.1 PC端
重啟 Tomcat 伺服器,存取 http://localhost,(本文存取本機,因此使用http://localhost,實際存取地址為 http://IP 。)即可進入 a.jsp 頁面,即可存取數據決策系統,如下圖所示:

2.4.2 行動端(HTML5 端存取)
重啟 Tomcat 伺服器,存取 http://IP ,如下圖所示:

注:App 端存取請參見本文 3.2 節。
3.1 遠端設計
遠端設計 輸入伺服器地址的時候,webroot 需省去,decision 要保留。
選項 | 值 |
---|
主機名/IP | 根據實際情況填寫 |
埠號 | 80 |
Web應用 | 空 |
Serverlet | decision |
帳號\密碼 | 根據實際情況填寫 |
配置工作區間如下圖所示:

3.2 行動端
App 端、H5 端、微信和釘釘整合環境下,輸入伺服器地址的時候,webroot 需要省去,但是 decision 一定要保留。
選項 | 值 |
---|
主機名/IP | 根據實際情況填寫 |
埠號 | 80 |
Web應用 | 空 |
Serverlet | decision |
帳號\密碼 | 根據實際情況填寫
|
配置工作區間如下圖所示:

4.1 IE9 瀏覽器下頁面顯示不完全
問題描述
按照上述配置部署好後, IE9 瀏覽器下,頁面顯示不完全。
解決方案
將本文2.2 步驟中的 a.jsp 檔案程式碼修改如下:
<html>
<head>
<title>FineReport</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge"/>
<link rel="stylesheet" type="text/css" href="/decision/file?path=/com/fr/web/core/css/leaflet.css&type=plain&parser=plain"/>
<style type="text/css">
html, body
{
margin: 0px 0px;
width: 100%;
height: 100%;
}
iframe
{
margin: 0px 0px;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<iframe id="reportFrame" src="decision" name="itemslist" frameborder="0"></iframe>
</body>
</html>