历史版本26 :Tomcat下通过IP直接访问数据决策系统 返回文档
编辑时间: 内容长度:图片数:目录数: 修改原因:

目录:

1. 实现步骤编辑

1.1 修改端口号
如果没有启动其他占有端口号80的网络程序,可以将Tomcat服务器的端口号设置为80,因为80端口是默认端口,这样我们在访问报表页面时就不需要在加上Tomcat服务器的端口号,重启tomcat服务器访问http://localhost/webroot/decision就可以访问平台了。
修改端口号在配置文件%tomcat_home%\conf\server.xml文件中修改,如下:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
222
1.2 欢迎界面
每个web服务器都有默认的欢迎界面,通过修改欢迎界面,以显示平台页面,然后再修改配置文件目录,就可以访问:http://localhost进入产品演示界面了。以%tomcat_home%/webapps/webroot/目录作为web服务器默认目录,在webroot中建一个a.jsp文件,该文件作为web服务器的默认主页。
a.jsp调用iframe集成平台产品演示界面,代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%> <html> <head> <title>FineReport报表</title> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <iframe id="reportFrame" src="decision" name="itemslist" frameborder="0" width="100%" height="100%"></iframe> </body> </html>
保存,重启tomcat服务器访http://localhost/webroot/a.jsp就可以显示产品演示界面了。效果如下:
222
1.3 建虚拟目录
通过修改配置文件建虚拟目录,首先,修改%tomcat_home%/conf/server.xml文件,在server.xml文件中,host标签之间添加上代码如下:
<Context path="" docBase="C:\webroot" debug="0" reloadable="true" />
说明:
path是说明虚拟目录的名字,如果你要只输入ip地址就显示主页,则该键值留为空;
docBase是虚拟目录的路径,默认的是%tomcat_home%/webapps/目录,但将报表工程webroot放在了%Tomcat_home%/webapps下,启动服务器时会加载该工程,再建立虚拟目录后,启动服务器时通过该配置文件又加载了一次webroot工程,即报表加载了两次,会报错,所以需将webroot工程放在别的目录下。这里将webroot放在C盘根目录下,docBase路径改为C:\webroot,选择报表目录webroot让该目录作为我的默认目录。debug和reloadable一般都分别设置成0和true。
修改%tomcat_home%/conf/web.xml文件,在web.xml文件最下面</web-app>标签之前,添加一段代码显示自定义欢迎界面a.jsp,在welcome-file节点中添加效果如下:
<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>
修改Tomcat部署的webroot\WEB-INF\web.xml,在</web-app>标签之前,添加一段代码,添加效果如下:
222
http://localhost就可以进入a.jsp页面,显示平台登录首页界面内容了:
222

2. 可能遇到的问题编辑

2.1 ie9下显示的问题

按照上述配置部署好后,假如ie9出现显示不完全的问题

尝试将a.jsp的demo代码修改为

<html> <head> <title>FineReport</title> <meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge"/> <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>

应该就可以解决。