初始安装Tomcat,访问时首页为默认的Tomcat首页信息,现在想要将首页设置成自己的项目页面。

修改Tomcat家目录下的conf中的server.xml文件

在<host></host>中添加选项,设置context:

<Host>

......

<Context><Context docBase="<项目名称>" path="" reloadable="true"  ></Context>

......

</Host>

保存退出

其中的docBase="<项目名称>"选项,填写你的在webapps下的项目名称,path为设置首页,如果需要IP+路径访问项目,将path设置为path=“/<项目名称>”,如果将此项目设置为首页,则将此值设置为空。

然后修改统计目录下的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>

以上是原配置,在<welcome-file-list> 及<welcome-file>index.html</welcome-file>中间添加

<welcome-file><首页配置文件></welcome-file>,如自己项目首页为aaa.jsp则整个配置为:

 <welcome-file-list>

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

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

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

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

    </welcome-file-list>

保存退出

aaa.jsp配置文件为项目中的配置文件,即webapps下项目目录下的首页配置文件名称。

在Web.xml文件当中有指定,会按照顺序去寻找aaa开头的文件

然后开启Tomcat访问首页,首页变成项目首页。

 

在Tomcat/webapps目录下有个ROOT目录,此目录存放Tomcat的基本配置信息,在开启Tomcat之后,若没有指定访问首页,则默认初始访问首页是访问的此目录下的项目,若访问首页设置为指定目录下的首页,则会变成指定的项目首页。