版权声明:借鉴时注明出处就行 https://blog.csdn.net/weixin_42144379/article/details/84901246
方法一:
也是最直接的办法,就是 删掉 webapp下的 ROOT 项目
然后把自己的项目更名为ROOT
方法二:
修改 tomcat 配置文件 conf 下面的 server.xml 在末尾有这么一段:
<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 标签 改变默认主页 -->
</Host>
在 结束标签 </Host> 前面加上 :
<Context path="" docBase="myProject" debug="0" reloadable="true" />
就可以了.
注意: 假如放在 webapp 下面的是 war 包,那么要重启一次 tomcat
第一次 解析war包为可用文件,解析后 在重启下 tomcat 就会找到你的 项目文件
还有,就是要在 项目的WEB-INF目录下的 web.xml 配置文件中 编写 项目起始页
一般会自动生成,把 index.html 或者 index.jsp改为你的 文件名即可
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>jacktu</display-name>
<welcome-file-list>
<!-- 此处是项目的起始页 -->
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>