修改tomcat 服务器默认主页

webapps下建了examples目录作为网站的默认目录,在examples中有一个index.html文件,让该文件作为网站的默认主页

一、修改$tomcat/conf/server.xml文件

<span style="color:#333333;">      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
	<Context path="" docBase="D:\eclipse-jee-mars-2-win32-x86_64\apache-tomcat-8.0.28\webapps\examples" debug="0" reloadable="true" />
        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />

      </Host></span>
增加部分   
	<Context path="" docBase="D:\eclipse-jee-mars-2-win32-x86_64\apache-tomcat-8.0.28\webapps\examples" debug="0" reloadable="true" />

注:<Context path="/helloapp" docBase="C:\chapter03\helloapp" reloadable="true"/>

以上<Context>元素的 docBase 属性指定了 helloapp 应用的绝对路径,为C:\chapter03\helloapp;path属性表明访问helloapp应用的URL入口为“/helloapp”。由于helloapp.xml文件位于Catalina/localhost/子目录下,因此helloapp应用将运行在名为Catalina 的 Engine 组件的 localhost 虚拟主机中。访问 helloapp应用中的 login.htm和hello.jsp的URL分别为: 

http://localhost:8080/helloapp/login.htm
http://localhost:8080/helloapp/hello.jsp

如果<Context path="" docBase="C:\ chapter03\helloapp" reloadable="true"/>

访问 helloapp应用中的 login.htm和hello.jsp的URL分别为: 

http://localhost:8080/login.htm
http://localhost:8080/hello.jsp

如果<Context path="/a" docBase="C:\chapter03\helloapp" reloadable="true"/>

访问 helloapp应用中的 login.htm和hello.jsp的URL分别为: 

http://localhost:8080/a/login.htm
http://localhost:8080/a/hello.jsp

如果  在web.xml中设置;

    <welcome-file-list>
        <welcome-file>login.htm</welcome-file>
        <welcome-file>hello.jsp</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

那么  可直接  使用

http://localhost:8080
http://localhost:8080/a/

<Host>元素代表虚拟主机,在同一个<Engine>元素下可以配置多个虚拟主机

path:指定该Web应用的URL入口

docBase:指定Web应用的文件路径,可以给定绝对路径,也可以给定相对于<Host>的appBase属性的相对路径。如果Web应用采用开放目录结构,则指定Web应用的跟目录;如果Web应用是个WAR文件,则指定WAR文件的路径workDir:指定Web应用的工作目录。Tomcat在运行时会与这个Web应用相关的临时文件放在次目录下

reloadable: 如果这个属性设为true,Tomcat服务器在运行状态下会监视在WEB-INF/classes和WEB-INF/lib目录下class文件的改 动,以及监视Web应用的WEB-INF/web.xml文件的改动。如果监测到有class文件被更新的,服务器会自动重新加载Web应用。该属性的默 认值为false。在Web应用的开发和调试阶段,把reloadable设为true,可以方便对Web应用的调试。在Web应用正式发布阶段,把 reloadable设为false,可以降低Tomcat的运行负荷,提高Tomcat的运行性能


二、 修改$tomcat/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>

根据需要修改你的默认主页

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值