如何设置Tomcat默认主页(指定欢迎页)?

王朝学院·作者佚名  2009-04-30  
宽屏版  字体: |||超大  

方法一:(适合对服务器中单个站点的设置)

(d:\demo\为站点根目录)

在Tomcat中,默认主页为:index.html,index.htm,index.jsp

如果需要使用其他页面作为默认主页,需要配置WEB-INF文件夹下的web.xml文件:

如上例中:

在D:\demo\WEB-INF\文件夹中建立文件web.xml:

内容如下:

<?xml version=”1.0″ encoding=”UTF-8″?>

<web-app version=”2.4″

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

<welcome-file-list>

<welcome-file>hello.jsp</welcome-file>

</welcome-file-list>

</web-app>

方法二:(以下设置将应用于该服务器下所有的站点)推荐使用

打开文件conf/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>

在中间加入你想要的文件名即可。

如:我想让hello.jsp成为默认首页,我将上面那段代码改成:

<welcome-file-list>

<welcome-file>hello.jsp</welcome-file>

<welcome-file>index.html</welcome-file>

<welcome-file>index.htm</welcome-file>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有