另个默认网页主目录只能放在tomcat安装目录下吗!不能像iis一样随便选择硬盘哪个目录都行?、

解决方案 »

  1.   

    修改TOMCAT_HOME/conf/server.xml文件
        <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
    port="80"               minProcessors="5" maxProcessors="75"
                   enableLookups="true" redirectPort="8443"
                   acceptCount="10" debug="0" connectionTimeout="20000"
                   useURIValidationHack="false" />
    改写port="80"为你希望的端口号码,安装时也可以设置主目录设置<Host>下的<Context>中的docBase=“你设置的目录”默认主文件在Tomcat_home/webapps/你的web应用目录/WEB-INF/下的web.xml文件中修改
    添加如下代码:
    <welcome-file-list>
        <welcome-file>index.html</welcome-file><!-- 可以有多个 -->
    </welcome-file-list>最后一个:你刷新一下
      

  2.   

    to:chenyankui(王京) 
    兄弟,那主目录可以设置tomcat安装目录以外的目录吗!我设置了其它目录总不成功!
    我是tomcat5,server.xml内容中只有:
    <!-- Example Server Configuration File -->
    <!-- Note that component elements are nested corresponding to their
         parent-child relationships with each other --><!-- A "Server" is a singleton element that represents the entire JVM,
         which may contain one or more "Service" instances.  The Server
         listens for a shutdown command on the indicated port.     Note:  A "Server" is not itself a "Container", so you may not
         define subcomponents such as "Valves" or "Loggers" at this level.
     --><Server port="8005" shutdown="SHUTDOWN" debug="0">
      <!-- Comment these entries out to disable JMX MBeans support -->
      <!-- You may also configure custom components (e.g. Valves/Realms) by 
           including your own mbean-descriptor file(s), and setting the 
           "descriptors" attribute to point to a ';' seperated list of paths
           (in the ClassLoader sense) of files to add to the default list.
           e.g. descriptors="/com/myfirm/mypackage/mbean-descriptor.xml"
      -->
      <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
                debug="0"/>
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
                debug="0"/>  <!-- Global JNDI resources -->
      <GlobalNamingResources>    <!-- Test entry for demonstration purposes -->
        <Environment name="simpleValue" type="java.lang.Integer" value="30"/>    <!-- 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">
        </Resource>
        <ResourceParams name="UserDatabase">
          <parameter>
            <name>factory</name>
            <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
          </parameter>
          <parameter>
            <name>pathname</name>
            <value>conf/tomcat-users.xml</value>
          </parameter>
        </ResourceParams>  </GlobalNamingResources>  <!-- A "Service" is a collection of one or more "Connectors" that share
           a single "Container" (and therefore the web applications visible
           within that Container).  Normally, that Container is an "Engine",
           but this is not required.       Note:  A "Service" is not itself a "Container", so you may not
           define subcomponents such as "Valves" or "Loggers" at this level.
       -->  <!-- Define the Tomcat Stand-Alone Service -->
      <Service name="Catalina">    <!-- A "Connector" represents an endpoint by which requests are received
             and responses are returned.  Each Connector passes requests on to the
             associated "Container" (normally an Engine) for processing.         By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
             You can also enable an SSL HTTP/1.1 Connector on port 8443 by
             following the instructions below and uncommenting the second Connector
             entry.  SSL support requires the following steps (see the SSL Config
             HOWTO in the Tomcat 5 documentation bundle for more detailed
             instructions):
             * If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
               later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
             * Execute:
                 %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
                 $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA  (Unix)
               with a password value of "changeit" for both the certificate and
               the keystore itself.         By default, DNS lookups are enabled when a web application calls
             request.getRemoteHost().  This can have an adverse impact on
             performance, so you can disable it by setting the
             "enableLookups" attribute to "false".  When DNS lookups are disabled,
             request.getRemoteHost() will return the String version of the
             IP address of the remote client.
        -->    <!-- Define a non-SSL Coyote HTTP/1.1 Connector on the port specified
             during installation  -->
        <Connector 
    port="8080"               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   debug="0" connectionTimeout="20000" 
                   disableUploadTimeout="true" />
        <!-- Note : To disable connection timeouts, set connectionTimeout value
         to 0 -->

    <!-- Note : To use gzip compression you could set the following properties :

       compression="on" 
       compressionMinSize="2048" 
       noCompressionUserAgents="gozilla, traviata" 
       compressableMimeType="text/html,text/xml"
    -->    <!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
        <!--
        <Connector port="8443" 
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" disableUploadTimeout="true"
                   acceptCount="100" debug="0" scheme="https" secure="true"
                   clientAuth="false" sslProtocol="TLS" />
        -->
      

  3.   

    我的server.xml和介绍的有区别!
    我的server.xml中host没有context项内容,其内容如下:而且是注释的
    <!--
    <Connector port="8082" 
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false"
                   acceptCount="100" debug="0" connectionTimeout="20000"
                   proxyPort="80" disableUploadTimeout="true" />
    -->
    另外修改端口也没有你说的内容:我的内容如下:
    <Host name="localhost" debug="0" appBase="webapps"
           unpackWARs="true" autoDeploy="true"
           xmlValidation="false" xmlNamespaceAware="false">
      

  4.   

    配置应用的文件都在Tomcat 5.0\conf\Catalina\localhost   下面了。COPY一个改一个就可以了。
      

  5.   

    在host里面加上<Context path="" docBase="" debug="1" reloadable="true" ></Context>
    "path"是你浏览时输入的url,如path="/csdn" 那在浏览时输入"http://localhost:8080/csdn" docBase是页面的物理存放位置
      

  6.   

    to:jeke342() 
    你说的方法copy改一下!是把文件名改一下!但我装好以后,这个目录下就有adim.xml,manager.xml等文件,我copy哪个呢!文件名又改成什么呢,随便取个名字有关系吗,这个文件的名字没有要求吧!我的应用又怎么和这个文件联系起来呢!在线等待~~~~~~~~~~
      

  7.   

    我是和eclipse一起装的,要在环境变量加入
    CATALINA_HOME = C:\Program Files\Apache Software Foundation\Tomcat 5.0(值为你安装TOMCAT路径)
    TOMCAT_HOME = C:/Program Files/Apache Software Foundation/Tomcat 5.0(值为你安装TOMCAT路径)最好用全安装
      

  8.   

    各位!俺初学者!有人说在/conf/localhost中copy一个文件改一下!而有的人说修改server.xml!到底是用那种方法
      

  9.   

    修改server.xml文件中的host元素,如下:
    <host name="www.yourweb.com">  <alias><Alias>mycompany.com</Alias>
    </host>
    这个主要在host中配置,请注意你需要的dns必须ip地址经过映射,要不然没用的.
    详细的你可以到你的catalina_home\webapps\tomcat-docs\config下看看host元素的介绍.
      

  10.   

    改 C:\Tomcat 5.0\conf\server.xml  文件!下面是我改的  看我的注释,  <Server port="8005" shutdown="SHUTDOWN" debug="0">
     
      <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
                debug="0"/>
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
                debug="0"/>  <!-- Global JNDI resources -->
      <GlobalNamingResources>    <!-- Test entry for demonstration purposes -->
        <Environment name="simpleValue" type="java.lang.Integer" value="30"/>    <!-- 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">
        </Resource>
        <ResourceParams 
                        name="UserDatabase">
          <parameter>
            <name>factory</name>
            <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
          </parameter>
          <parameter>
            <name>pathname</name>
            <value>conf/tomcat-users.xml</value>
          </parameter>
        </ResourceParams>  </GlobalNamingResources>
     
      <Service name="Catalina">
    <!-- 这里的端口号 把 8080 改成你需要的端口号就可以了-->
          <Connector port="8080"              
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   debug="0" connectionTimeout="20000" 
                   disableUploadTimeout="true" />
             <Connector port="8009" 
                   enableLookups="false" redirectPort="8443" debug="0"
                   protocol="AJP/1.3" />         <Engine name="Catalina" defaultHost="localhost" debug="0">      
          <Logger className="org.apache.catalina.logger.FileLogger"
                  prefix="catalina_log." suffix=".txt"
                  timestamp="true"/>     
          <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                     debug="0" resourceName="UserDatabase"/>       <Host name="localhost" debug="0" appBase="webapps"
                unpackWARs="true" autoDeploy="true"
                xmlValidation="false" xmlNamespaceAware="false">
                
                <!-- 在这里配置 虚拟目录 PATH是告诉浏览器要访问的路径 dobase是你文件夹的物理路径   http://localhost:8080/beyond/firster2.jsp 访问的就是d:/jsp/firster2.jsp文件-->
                <Context path="/beyond" docBase="D:/jsp" debug="1" reloadable="true" ></Context>         
            <Logger className="org.apache.catalina.logger.FileLogger"
                    directory="logs"  prefix="localhost_log." suffix=".txt"
                    timestamp="true"/>      </Host>    </Engine>  </Service></Server>
      

  11.   

    to:mfc2003(抗战二十年(november rain))
    我要把tomcat默认主页目录改成d:/jsp怎么办呢?
      

  12.   

    D:\Tomcat 5.5\conf\Catalina\localhost\ROOT.xml <?xml version='1.0' encoding='utf-8'?>
    <Context displayName="Welcome to Tomcat" docBase="E:\logistic" path=""  reloadable="true">
    <Resource name="jdbc/default" auth="Container" description="DB Connection" type="javax.sql.DataSource" 
    maxActive="20" 
    maxIdle="4" 
    maxWait="10000"
    username="sa" 
    password="" 
    driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
    url="jdbc:odbc:trade_mis"
    />
    </Context>