在tomcat\conf的文件server.xml中增加
 
<Context path="/test" docBase="F:\\abc\\def" debug="0" reloadable="true" > 
        </Context>

解决方案 »

  1.   

    你可以在server.xml
    加入!
    <host name="127.0.0.1">
    <context path="/test" docbase="F:\\abc\\def"/>
    </host>
      

  2.   

    我这样设了,但是报错:
    PARSE error at line 156 column 11
    org.xml.sax.SAXParseException: The content of element type "web-app" must match
    "(icon?,display-name?,description?,distributable?,context-param*,servlet*,servle
    t-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,
    resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-r
    ef*)".
      

  3.   

    server.xml文档有其dtd规范其格式,报这样的错是因为你新添加的元素放在不正确的位置下面,参照例子把他放在正确的位置就可以了
    context 元素应该是放在 ContextManager 元素里面.这要看具体的dtd文件
      

  4.   

    例子: 一个典型的server.dtd
    <?xml version="1.0" encoding="ISO-8859-1"?><!ELEMENT Server (ContextManager+)>
    <!ATTLIST Server
        adminPort NMTOKEN "-1"
        workDir CDATA "work"><!ELEMENT ContextManager (Context+, Interceptor*, Connector+)>
    <!ATTLIST ContextManager
        port NMTOKEN "8080"
        hostName NMTOKEN ""
        inet NMTOKEN ""><!ELEMENT Context EMPTY>
    <!ATTLIST Context
        path CDATA #REQUIRED
        docBase CDATA #REQUIRED
        defaultSessionTimeOut NMTOKEN "30"
        isWARExpanded (true | false) "true"
        isWARValidated (false | true) "false"
        isInvokerEnabled (true | false) "true"
        isWorkDirPersistent (false | true) "false"><!ELEMENT Interceptor EMPTY>
    <!ATTLIST Interceptor
        className NMTOKEN #REQUIRED
        docBase   CDATA #REQUIRED>    <!ELEMENT Connector (Parameter*)>
    <!ATTLIST Connector
        className NMTOKEN #REQUIRED><!ELEMENT Parameter EMPTY>
    <!ATTLIST Parameter
        name CDATA #REQUIRED
        value CDATA "">可以看到 ContextManager元素中可以包含一个或多个context.举个实现的例子,就是在server.xml的具体写法,省略了一些属性:
    <Server>
    <ContextManager>
    <Context></Context>
    </ContextManager>
    </Server>
      

  5.   

    我这样写了之后不报错了,但是找不到test目录,设置无效。
    <ContextManager>
      <Context path="/test" docBase="F:\\codeFactory\\test" debug="0" privileged="true"/>
    </ContextManager>
    改成这样也不行:
    <ContextManager>
      <Context path="/test" docBase="F:/codeFactory/test" debug="0" privileged="true"/>
    </ContextManager>
      

  6.   

    我的server.xml里没有<ContextManager></ContextManager>
    这个,用不用加上去