1、默認的項目都在目錄:apache-tomcat-9.0.0.M22\webapps\ROOT下
2、該目錄下有一個index.jsp是tomcat的默認主頁,如下
3、現在需要修改這個默認主頁,改成自己的主頁
(1)修改配置文件server.xml(在conf目錄下),找到如下代碼:
<Host name="172.18.0.5" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="C:\apache-tomcat-9.0.0.M22\webapps\ROOT"/>
修改第三行為<Context path="" docBase="C:\apache-tomcat-9.0.0.M22\webapps\ROOT\1" debug="0"/>
其中C:\apache-tomcat-9.0.0.M22\webapps\ROOT\1就是你想設置的網站根目錄,我這里的根目錄就是1
(2)修改配置文件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>work_detail.html</welcome-file>,注意:work_detail.html是目錄1下的文件
<welcome-file-list> <welcome-file>work_detail.html</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list
4、重啟tomcat,訪問172.18.0.5:8080
OK,訪問的根目錄就是剛剛設置的目錄文件了