功能需求:访问localhost:8080  直接访问项目页面(如果去掉端口号访问,把server.xml 中8080端口修改成80)

百度百科:

80端口是为HTTP(HyperText Transport Protocol)即端口号都是80,因此只需输入网址即可,不用输入“:80”了。

配置实现:

war 包放在tomcat文件下webapps下

D:\tomcat\apache-tomcat-8.5.33\webapps

打开server.xml

D:\tomcat\apache-tomcat-8.5.33\conf\server.xml

第一种:如图加上

   <Context path="" docBase="项目名" debug="0" reloadable="true"/>
这种方法会造成项目启动加载2次
 <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
            
            <!-- 改默认的设置项目名  -->
        <Context path="" docBase="项目名" 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 &quot;%r&quot; %s %b" />

      </Host>

第二种

<Context path="" docBase="项目名" debug="0" reloadable="true"/>

换成
   <Context path="" docBase="D:\tomcat\apache-tomcat-8.5.33\webapps\项目名" debug="0" />
D:\tomcat\apache-tomcat-8.5.33\webapps\项目名 为项目绝对路径

 

相关文章:

  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2021-12-03
  • 2021-12-08
  • 2021-10-09
  • 2022-12-23
猜你喜欢
  • 2022-01-03
  • 2021-05-26
  • 2021-12-19
  • 2022-12-23
  • 2021-12-04
  • 2021-11-16
相关资源
相似解决方案