Tomcat设置首页

初始安装Tomcat,访问时首页为默认的Tomcat首页信息,如今想要将首页设置成本身的项目页面。html

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

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

<Host>webapp

......jsp

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

......xml

</Host>htm

保存退出配置

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

而后修改统计目录下的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以后,若没有指定访问首页,则默认初始访问首页是访问的此目录下的项目,若访问首页设置为指定目录下的首页,则会变成指定的项目首页。

相关文章
相关标签/搜索