改變tomcat的默認訪問頁面


一、需要下載一個tomcat,這里演示采用tomcat8。

 

二、打開tomcat-1.8\webapps:

       新建example文件,在example下新建test.html,添加如下內容:

      

<!DOCTYPE HTML><html lang="en"><head>
<meta charset="UTF-8">
<title>Apache Tomcat Examples</title>
</head>
<body>
<p>
<h3>Apache Tomcat Examples</H3>
<p></p>
<ul>
<li><a href="servlets">Servlets examples</a></li>
<li><a href="jsp">JSP Examples</a></li>
<li><a href="websocket/index.xhtml">WebSocket Examples</a></li>
</ul>
</body></html>

  

三、打開tomcat-1.8\conf下的server.xml文件:

     找到如下標簽<Host></Host>:

    

    <Host name="localhost"  appBase="webapps"
          unpackWARs="true" autoDeploy="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>

 

 

   修改成如下,添加了(<Context path="" docBase="example" reloadable="true"/>),docBase=剛剛新建的項目名example:

   

 <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="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" />
      <Context path="" docBase="example"  reloadable="true"/>

      </Host>

  

四、打開tomcat-1.8\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>

  修改為,添加剛剛新建的test.html:

 <welcome-file-list>
	    <welcome-file>test.html</welcome-file>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

  

五、打開tomcat-1.8\bin,雙擊startup.bat啟動tomcat:

       在瀏覽器輸入localhost:8080:

 

 

     可以看到默認的頁面變成了我們指定的頁面

 

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM