tomcat配置啟動埠和默認專案默認404
1、tomcat配置啟動埠
tomcat檔案夾conf檔案下的server.xml檔案中配置tomcat的啟動埠和關閉埠
<!-- 改標簽內可以設定tomcat啟動的埠-->
<Connector connectionTimeout="20000"
port="8080"
protocol="HTTP/1.1"
edirectPort="8443"
URLEncoding="UTF-8"
/>
2、配置tomcat默認啟動專案
在沒有任何配置的情況下tomcat默認的啟動頁面是這樣的

需要訪問自己的專案的話需要在后面添加localhost:8080/專案名,這樣會很麻煩,我們可以把自己的專案配置成默認啟動專案,
2.1、方法一
將自己的專案的名稱改為ROOT,替換webapps里的ROOT,這樣的話有多個專案切換的非常的不方便,

2.2、方法二
可以修改組態檔切換自己的專案為tomcat啟動時的默認專案
<!-- 在conf檔案下的server.xml檔案中修改配置
在該檔案中找到host節點
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
</host>
在</host>上面添加<Context path="" docBase="StudentManager" debug="0"/>
-->
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt"/>
<Context path="" docBase="StudentManager" debug="0"/>
</Host>
<!--
docBase為專案路徑(這里我用的相對路徑),推薦使用絕對路勁
-->

這樣修改完后重新啟動tomcat,會發現默認的頁面就改成了自己的專案頁面
3、修改tomcat默認自帶的404、500、400頁面
首先準備一個404的頁面,將html/jsp的頁面放在webapps/ROOT下

我的頁面如下(有點丑)

然后修改conf檔案下web.xml組態檔
<!--
在改檔案的最后</web-app>節點上面添加
-->
<error-page>
<error-code>404</error-code>
<location>/error.html</location>
</error-page>
這樣你再訪問不存在的頁面就會,出現自己設定的404頁面
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/261471.html
標籤:其他
下一篇:Linux命令基本使用(下)
