tomcat下设置默认的启动项目方式

我们如果直接讲web项目部署在服务器的tomcat上面,在访问的时候需要添加项目名称,那么我们如果怎样去掉这个项目名称呢?下面提供两种方式

第一种:在<Host name=“localhost” appBase=“webapps” 节点下面添加

docBase:代表项目的绝对路径。也可以使用相对路径。

path:代表访问时的项目名称,当path="/" 在访问的时候就可以不用添加项目名称,如下样例:

<Context path="/" docBase="/project/tomcat7/webapps/cxg-interactiveweb" reloadable="false" allowLinking="true"></Context>

    <!-- 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>	

第二种方式:将项目下的文件复制放到tomcat的webapps/ROOT目录下

所有的项目都在webapps目录里面,root是其中的一个项目,浏览器访问http://localhost:8080/ 其实是默认访问root项目。

猜你喜欢

转载自blog.csdn.net/huangyaa729/article/details/84644646