例如: 
<Context path="/manager" docBase="manager" 
         debug="0" privileged="true"/>
 <Context path="/sun" docBase="sun" 
         debug="0" privileged="true"/>
 <Context path="/syw" docBase="syw" 
         debug="0" privileged="true"/>
 <Context path="/test" docBase="test" 
         debug="0" privileged="true"/>
 <Context path="/SQL" docBase="SQL" 
         debug="0" privileged="true"/>
 <Context path="/time" docBase="time" 
         debug="0" privileged="true"/>
这样就可以的

解决方案 »

  1.   

    <Host>中有一个appBase的属性,用来定义整个虚拟主机(由Host指定的虚拟主机)目录,这个目录是指定要在此虚拟主机上运行的web应用的路径。这个目录可以是一个绝对路径,也可以是一个相对路径(相对于CALALINA_HOME)。如果未设置此属性,系统会默认为一个相对路径webapps(这时如果CATALINA_HOME为d:\tomcat41,那么此时的虚拟主机上的web应用路径为d:\tomcat41\webapps)。接着可以用Host的子元素(element)Context来设置你的web应用资源文件的具体的存放路径。见楼上给出的例子。
      

  2.   

    呵呵,我看我存的这个文档到底可以赚多少分~~~1.问:Tomcat 中如何设置多个虚拟路径?
    答:
    a.   server.xml位置:tomcat\conf\server.xml
    b.   设置虚拟路径通过修改增加server.xml中的 <context> ..</context>中的内容来实现。
    C.   能设置多个虚拟路径吗?能。 说明:各虚拟路径下的.jsp,servlet完全没有关联,各自独立,该路径下不能调用其它路径下的servlet
    d.   修改前源文件的<context> ..</context>内容如下,特别长!!如果要删除这个虚拟路径必须把下面的全部内容删除(注释掉)。
        <!-- Tomcat Examples Context -->
            <Context path="/examples" docBase="examples" debug="0"
                     reloadable="true" crossContext="true">
              <Logger className="org.apache.catalina.logger.FileLogger"
                         prefix="localhost_examples_log." suffix=".txt"
                  timestamp="true"/>
              *********中间省略了六十行代码,,,请注意每个<context>跟</context>都有对应的。
             *****初手可能会在这里犯错!!!!!
              <ResourceLink name="linkToGlobalResource"
                        global="simpleValue"
                        type="java.lang.Integer"/>
            </Context>
    e:增加两个虚拟路径
     其中path代表虚拟目录名称,在网址中使用,如:http://localhost:8080/path1
     docbase代表jsp文件的实际路径,后面的几个参数使用默认参数即可。        <Context path="/path1" docBase="D:\jspsource" debug="0"
                     reloadable="true" crossContext="true" />
                     
            <Context path="/path2" docBase="D:\jspsource2" debug="0"
                     reloadable="true" crossContext="true" />
    也可以用如以形式:        <Context path="/path1" docBase="D:\jspsource" debug="0"
                     reloadable="true" crossContext="true" >  </context>
                     
            <Context path="/path2" docBase="D:\jspsource2" debug="0"
                     reloadable="true" crossContext="true" />  </context>初手容易犯的错误:将自己写的context放在默认的eaxmples的context后面
    如这样;
            <Context path="/examples" docBase="examples" debug="0"
                     reloadable="true" crossContext="true">
            <Context path="/path1" docBase="D:\jspsource" debug="0"
                     reloadable="true" crossContext="true" />
     <Logger className="org.apache.catalina.logger.FileLogger"
                         prefix="localhost_examples_log." suffix=".txt"
                  timestamp="true"/>....这就大错特错了!!!
     <Context path="/examples" docBase="examples" debug="0"
                     reloadable="true" crossContext="true">跟后面的一个</context>对应着,这个<context>在很后面,你要看清楚了^_^
    2.配置servlet时的疑问首先要注意,servlet对应的.class不能直接放在D:\jspsource\WEB-INF\classes目录下,必须为每个servlet放在包里,就是java文件的开头要package ..才行。
    我的servlet的.class放置为: D:\jspsource\WEB-INF\classes\globalPackage\EchoRequestServlet.class
    EchoRequestServlet.java的开头当然还需要:
    package globalPackage;
    ...问:调用一个servlet需要做哪些事?
    答: 将servlet对应的  文件夹\xxx.class  放在D:\jspsource\WEB-INF\classes目录下
         配置web.xml文件
         写jsp文件,其中可以调用你写的servlet了问:将D:\jspsource设为虚拟路径path1后,jsp,servlet放在哪个目录?
    答:下面要自己动手  增加 目录及相关文件  .jsp和.class放在相关目录下。D:\jspsource下新建文件夹 WEB-INF  ( 文件夹名一定要大写)D:\jspsource\WEB-INF下新建文件夹classes  (此处要小写)
    (D:\jspsource\WEB-INF\classes)问:将.class放在D:\jspsource\WEB-INF\classes 后还需要增加该目录到环境变量classpath里面吗?
    答:不需要。tomcat会自动找到 虚拟目录对应的实际目录下的  WEB-INF\classes的.class文件servlet的.class放置好后该配置web.xml了,不然还是找不到servlet的.class。
    问:web.xml文件找不到?在哪里?
    答:一般第一次需要你自己新建,放置到  D:\jspsource\WEB-INF目录下:即:D:\jspsource\WEB-INF\web.xml
    新建太麻烦了,还要自己手写很多代码。现在可以这样做:在你下载tomcat的文件夹里面有一个web.xml,路径为:C:\Tomcat\webapps\ROOT\WEB-INF
    把里面的web.xml  copy到我们的D:\jspsource\WEB-INF   文件夹下。
    第一次建好web.xml之后,以后只需要在里面改配置就可以了。问:增加一个servlet后如何配置web.xml
    答:我增加了一个D:\jspsource\WEB-INF\classes\globalPackage\EchoRequestServlet.class文件,需作如下修改<servlet>
           <servlet-name>EchoRequestServlet</servlet-name>
       <servlet-class>globalPackage.EchoRequestServlet</servlet-class>
       </servlet>
       <servlet-mapping>
           <servlet-name>EchoRequestServlet</servlet-name>
       <url-pattern>/servlet/EchoRequest</url-pattern>
       </servlet-mapping>增加位置:

    <web-app>
      <display-name>Welcome to Tomcat</display-name>
      <description>
         Welcome to Tomcat
      </description>跟
    </web-app>
    之间。说明:  <servlet-class> 为类名,注意前面肯定要包名的,因为servlet的类必须放在包里,前面已经说过。
    <url-pattern>指访问此servlet时用这个路径访问,在.jsp文件中只用到它。自己随便填什么都行,不过别太离谱^_^servlet的class放好了,也配置好了。现在写jsp访问呵。问:我照书上写的<form method="Post" action="/servlet/EchoRequest">  怎么最后访问网页时还是报错说找不到类。
    把action后的/去掉试试...即: <form method="Post" action="servlet/EchoRequest">... 应该可以了吧^_^3
    附:
    问:怎么报错:description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL). 答:我写代码又马乎了:(  我的form提交用的post,,,而servlet中重写的是doGet  ,不一致~~~~~~~