新加的虚拟主机和虚拟目录就是不能共存,
若在默认的LOCALHOST下增加一个虚拟路径是OK的
  <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
<Context path="/aaa" docBase="e:/www" debug="0" crosscontext="true" reloadable="true" />
.........
新增加的虚拟主机这样配置的话只能访问虚拟主机,访问www.a.com:8080 就 OK
  <Host name="www.a.com" debug="0" appBase="E:\a" >
                     <Context path="" docBase="." debug="0" reloadable="true" crossContext="true" /></Host>若改成 访问www.a.com:8080/bbb 就 OK , 访问www.a.com:8080就找不到页面
  <Host name="www.a.com" debug="0" appBase="E:\a" >
                     <Context path="/bbb" docBase="E:\bbb" debug="0" reloadable="true" crossContext="true" /></Host>搞了很久解决不掉!~求高人!

解决方案 »

  1.   

    补充:我也试过将默认的LCOALHOST虚拟主机的配置内容,复制了一个,再在此基础上修改,还是一样
      

  2.   

    你是想www.a.com:8080和www.a.com:8080/bbb都能访问,
    是不是应该两行都配置:<Host name="www.a.com" debug="0" appBase="E:\a" > 
      <Context path="" docBase="." debug="0" reloadable="true" crossContext="true" />                    
      <Context path="/bbb" docBase="E:\bbb" debug="0" reloadable="true" crossContext="true" /> 
    </Host> 
      

  3.   

    如楼上的配置,www.a.com:808能访问   www.a.com:8080/bbb找不到页面
      

  4.   

    还是把配置文件贴出来
    <Server port="8005" shutdown="SHUTDOWN">
      <Listener className="org.apache.catalina.core.AprLifecycleListener" />
      <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
      <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
       <GlobalNamingResources>
        <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
         <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>
      <Service name="Catalina">
        <Connector
    port="8080"               maxHttpHeaderSize="8192"
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   connectionTimeout="20000" disableUploadTimeout="true" />    <!--
        <Connector port="8443" maxHttpHeaderSize="8192"
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" disableUploadTimeout="true"
                   acceptCount="100" scheme="https" secure="true"
                   clientAuth="false" sslProtocol="TLS" />
        -->    <!-- Define an AJP 1.3 Connector on port 8009 -->
        <Connector port="8009" 
                   enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
         <!--
        <Connector port="8082" 
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" acceptCount="100" connectionTimeout="20000"
                   proxyPort="80" disableUploadTimeout="true" />
        -->
        <!-- You should set jvmRoute to support load-balancing via AJP ie :
        <Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">         
        --> 
        <Engine name="Catalina" defaultHost="localhost">
          <!--
          <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
          -->
          <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                 resourceName="UserDatabase"/>
          <!--
          <Realm className="org.apache.catalina.realm.MemoryRealm" />
          -->
           <!--
          <Realm  className="org.apache.catalina.realm.JDBCRealm"
                 driverName="org.gjt.mm.mysql.Driver"
              connectionURL="jdbc:mysql://localhost/authority"
             connectionName="test" connectionPassword="test"
                  userTable="users" userNameCol="user_name" userCredCol="user_pass"
              userRoleTable="user_roles" roleNameCol="role_name" />
          -->
          <!--
          <Realm  className="org.apache.catalina.realm.JDBCRealm"
                 driverName="oracle.jdbc.driver.OracleDriver"
              connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
             connectionName="scott" connectionPassword="tiger"
                  userTable="users" userNameCol="user_name" userCredCol="user_pass"
              userRoleTable="user_roles" roleNameCol="role_name" />
          -->      <!--
          <Realm  className="org.apache.catalina.realm.JDBCRealm"
                 driverName="sun.jdbc.odbc.JdbcOdbcDriver"
              connectionURL="jdbc:odbc:CATALINA"
                  userTable="users" userNameCol="user_name" userCredCol="user_pass"
              userRoleTable="user_roles" roleNameCol="role_name" />
          -->      <!-- 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">
    <Context path="/aaa" docBase="e:/www" debug="0" crosscontext="true" reloadable="true" />
         
            <!--
            <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
                     managerClassName="org.apache.catalina.cluster.session.DeltaManager"
                     expireSessionsOnShutdown="false"
                     useDirtyFlag="true"
                     notifyListenersOnReplication="true">            <Membership 
                    className="org.apache.catalina.cluster.mcast.McastService"
                    mcastAddr="228.0.0.4"
                    mcastPort="45564"
                    mcastFrequency="500"
                    mcastDropTime="3000"/>            <Receiver 
                    className="org.apache.catalina.cluster.tcp.ReplicationListener"
                    tcpListenAddress="auto"
                    tcpListenPort="4001"
                    tcpSelectorTimeout="100"
                    tcpThreadCount="6"/>            <Sender
                    className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
                    replicationMode="pooled"
                    ackTimeout="15000"/>            <Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
                       filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
                       
                <Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
                          tempDir="/tmp/war-temp/"
                          deployDir="/tmp/war-deploy/"
                          watchDir="/tmp/war-listen/"
                          watchEnabled="false"/>
            </Cluster>
            -->        
            <!--
            <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
            -->
            <!--
            <Valve className="org.apache.catalina.valves.AccessLogValve"
                     directory="logs"  prefix="localhost_access_log." suffix=".txt"
                     pattern="common" resolveHosts="false"/>
            -->
             <!--
            <Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
                     directory="logs"  prefix="localhost_access_log." suffix=".txt"
                     pattern="common" resolveHosts="false"/>
            -->      </Host>   <Host name="www.a.com" debug="0" appBase="E:\a" unpackWARs="true" autoDeploy="true"
           xmlValidation="false" xmlNamespaceAware="false">
                         <Context path="" docBase="." debug="0" reloadable="true" crossContext="true" /></Host>
                     <Context path="/bbb" docBase="E:\bbb" debug="0" reloadable="true" crossContext="true" />
           <Host name="www.b.com" debug="0" appBase="E:\b">
                  <Context path="" docBase="." debug="0"/>
           </Host>
        </Engine>  </Service></Server>
      

  5.   


    再确认一个问题,你所说的www.a.com:8080/bbb找不到页面,
    你有没有试着直接访问下面的文件,
    比如,你在 E:\bbb 目录下随便建立一个 a.htm空文件,访问:http://www.a.com/8080/bbb/a.htm试试?
      

  6.   

    谢谢提醒,结果仍然一样,似乎它就没把/bbb看作虚拟路径,而是主目录下的一个文件夹