读书人

设立Tomcat默认显示页面

发布时间: 2012-09-08 10:48:07 作者: rapoo

设置Tomcat默认显示页面
在server.xml中,有一段如下:
……

<engine name="Catalina" defaultHost="localhost">   <host name="localhost" appBase="webapps"       unpackWARs="true" autoDeploy="true"       xmlValidation="false" xmlNamespaceAware="false">   ……   <host></engine>

……
在<host></host>标签之间添加上:
类似如此:
<Context path="\UserManageDemo" docBase="D:\JavaStudy\UserManageDemo" debug="0" reloadable="true"/><!--<Context path="" docBase="D:\apache-tomcat-5.5.20\webapps\SSHExam" debug="0" reloadable="true"/>-->

path是说明虚拟目录的名字,如果你要只输入ip地址就显示主页,则该键值留为空;
docBase是虚拟目录的路径,它默认的是$tomcat/webapps/ROOT目录,
debug和reloadable一般都分别设置成0和true。
debug 与这个Engine关联的Logger记录的调试信息的详细程度。数字越大,输出越详细。如果没有指定,缺省为0。 也就是程序异常时写入日志文件里的详细程度。

然后,修改$tomcat/conf/web.xml文件。($tomcat就是Tomcat的安装文件夹)
在web.xml文件中,有一段如下:
   <welcome-file-list>        <welcome-file>index.html</welcome-file>        <welcome-file>index.htm</welcome-file>        <welcome-file>index.jsp</welcome-file>    </welcome-file-list>

如果想显示的主页是a.jsp
在<welcome-file-list>与<welcome-file>index.html</welcome-file>之间添加上:
<welcome-file>a.jsp</welcome-file>

保存上述两个文件后重启tomcat,在浏览器地址栏内输入域名,就可以显示自己项目的主页了.

读书人网 >软件架构设计

热点推荐