`
huzezhen1
  • 浏览: 7229 次
  • 性别: Icon_minigender_1
  • 来自: 惠州
社区版块
存档分类
最新评论

Tomcat默认打开项目设置

 
阅读更多

Tomcat在浏览器中输入:http://localhost:8080/ 后默认打开tomcat的管理界面,但是项目发布以后不希望这样,希望输入该地址后,

显示你希望代开的项目,所以需要以下更改

具体如下:

找到Tomcat的安装路径,打开conf文件夹中的server.xml文件:加入

以下代码,为红色代码部分

<Context path="" debug="0" docBase="E:\javasoft\Tomcat 6.0(Tomcat 7.0)\webapps\默认打开你的项目名" />
修改后的server.xml文件为下面所示,经测试,6.0和7.0都没问题的。

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container", 
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
  
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="150" minSpareThreads="4"/>
    -->
    
    
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    -->           
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->       

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <!-- 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 -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->
  <Context path="" debug="0" docBase="E:\javasoft\Tomcat 6.0(Tomcat 7.0)\webapps\默认打开你的项目名" />
      </Host>
    </Engine>
  </Service>
</Server>

 

另一种方法,将项目拷贝到webapps下,并将项目名称改为ROOT;不过可能会出现路径问题。

分享到:
评论

相关推荐

    设置tomcat默认打开的项目

    2.在里面添加下面一句话 其中docBase为项目绝对路径,path为相对路径(相对于默认的webapps的路径) 此时使path为空,访问localhost即访问webapps也即访问docBase 打开安装目录下的bin文件找到startup.bat点开启动...

    linux修改tomcat默认访问项目的具体步骤(必看篇)

    tomcat服务器的默认访问路径是webapps目录下的ROOT。如果更改tomcat服务器下的默认访问工程,需要修改tomcat/conf/server.xml配置文件。 打开server.xml可以找到类似下面的配置: unpackWARs=true autoDeploy=...

    扩大Tomcat内存

    Tomcat默认可以使用的内存有限的,在较大型的应用项目中,可能会出现内存不够用的情况,需要调大。现总结有以下几种扩大Tomcat内存的方法可以选用: 方法一:这种方法是在Tomcat使用startup.bat文件启动项目的情况下...

    jsp项目中更改tomcat的默认index.jsp访问路径的方法

    如何更改tomcat的默认index.jsp访问路径,jsp的工程下有一个叫做WEB-INF文件夹下的web.xml打开它,按照下面的方法即可修改

    Eclipse正常启动tomcat,但是访问httplocalhost8080 报404异常处理方法

    打开eclipse的server视图,双击配置好的那个tomcat,出现tomcat配置窗口,看到那个server location 是不是选第一项(默认是第一项),请选到第二项。如果这3项都是灰色的,请删除配置好的tomcat,再重新配置一次,...

    10、修改tomcat端口项目1

    1、修改8080端口为80811、tomcat的默认端口是8080,但该端口不是tomcat的唯一端口,可以通过修改tomat的配置文件进行修改,打开tomca

    Tomcat面试专题及答案.pdf

    1)直接把 Web 项目放在 webapps 下,Tomcat 会自动将其部署 2)在 server.xml 文件上配置节点,设置相关的属性即可 3)通过 Catalina 来进行配置:进入到 conf\Catalina\localhost 文件下,创建一个 xml 文件,该...

    如何查看tomcat的控制台输出的方法

    在web项目调试期间,时常需要查看输出的调试信息,例如当Hibernate设置为显示SQL语句时,每次运行的SQL语句会输出到终端,另外有时需要在代码中插入一些输出语句,以方便掌握运行情况,但当插入System.out.println...

    【JavaWeb】tomcat服务器访问硬盘中的文件(图片示例)

    1.找到tomcat的安装路径打开server.xml文件 打开conf文件夹,再用记事本打开conf里面的server.xml文件 ...8080是tomcat默认占用的端口号 /images是server.xml中配置的path的值 1.jpg是访问的文件名 到此就能访问到

    Docker添加tomcat容器无法访问首页解决方案

    使用阿里云获取tomcat镜像默认版本为8.5.51,其webapps文件为空,其欢迎页都放在webapps.dist文件中,也正因此我们才会访问出错 解决方法 将原本的webapps删除或该为别的名字,将webapps.dist改名为webapps 操作步骤...

    Tomcat服务器响应过慢解决方案

     使用top命令查看服务器的资源使用情况,主要分析CPU和内存的使用情况(top 命令是 Linux 下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,默认5秒刷新一下进程列表,所以类似于 Windows 的任务...

    Java项目开发与毕业设计指导

    使用Eclipse导入项目ch09, 在src/config.properties中配置数据库连接信息, 然后部署项目、启动tomcat。 访问http://localhost:8080/ajax即可启动本程序。 Ch10:一个简单的编译器实现 安装JDK、配置环境变量,...

    HBuilderX配置tomcat外部服务器查看编辑jsp界面的方法详解

    打开工具设置,找运行设置,外部web服务器调用url,输入http://localhost:8080后面的端口号是自己tomcat的默认端口,如果没有修改过就是8080,我因为修改成80端口(80端口可不写),所以配置中并未填写,注意下面的...

    java之路-项目搭建

    1.设置SVN,并检出为项目 先打开eclipse的svn视图,下面创建SVN源,及检出步骤 首先要有一个SVN地址:svn://svnhost.cn/groupCMS 直接检出为项目(如果你的SVN里存的不是项目,或者是新的项目,可以选择按新建项目检出) ...

    项目申报系统(jsp+sql2000)

    在选择数据库对话框中单击“下一步”,出现数据库设置对话框,不用改变默认的设置,单击“完成”按钮,完成数据源的建立。 5.数据的操作 将exam,firm,opendb三个文件夹拷贝到Tomcat/common/classes下。这样在地址...

    关于Tomcat在网页访问目录出现的404问题

    b: 打开apache的安装目录下的webapps目录,在该目录下是否有你的项目在里面? 都到这一步了,应该没有的吧 。 在Overview 模块内操作: 默认是选择 Use workspace metadata(dose not modify Tomcat installation) ...

    微信小程序+校园+表白墙+失物招领+二手交易+论坛+兼职+拼车+活动(前后端源码).zip

    工具(IDEA(maven),tomcat,mysql(5.6以上)使用maven下载依赖以后方可启动,默认使用外置tomcat,不懂设置就默认启动就行) 1.打开前台代码先修改app.js去配置服务器地址和oss的地址(用于展示图片) 2.打开前台util/config...

Global site tag (gtag.js) - Google Analytics