zoukankan      html  css  js  c++  java
  • Tomcat 映射虚拟目录

    ①在server.xml中添加如下蓝色代码:

     <Context path="/me" docBase="F:a" />

    </Host>

    还有一个属性reloadable="true",设成true,web应用一旦更改服务器就会自动加载,不需重启服务器。

    然后重启Tomcat,则可以直接访问:http://localhost:8080/me/1.html 来访问F:a文件夹下的文件1.html。

    在F:Tomcat 7.0confcontext.xml中配置则可以被所有web应用共享。

    原文:In the $CATALINA_BASE/conf/context.xml file: the Context element information will be loaded by all webapps.

    ②在$CATALINA_BASE/conf/[enginename]/[hostname]/  也就是 F:Tomcat 7.0confCatalinalocalhost 下添加新文件:bbb.xml 置入以下内容

    <?xml version="1.0" encoding="UTF-8" ?>
    <Context docBase="F:a" />

    则可以通过http://localhost:8080/bbb/1.html来访问F:a文件夹下的文件1.html。此方法不需要重启Tomcat。

     ③将方法②中的bbb.xml改名为ROOT.xml

    则可以通过http://localhost:8080/1.html来访问F:a文件夹下的文件1.html。此方法需要重启Tomcat。

    ④将方法②中bbb.xml改名为A#B#C.xml

     则可以通过http://localhost:8080/A/B/C/1.html来访问F:a文件夹下的文件1.html。此方法不需要重启Tomcat。

    测试以上内容的时候请注意随时清IE缓存。

    原文:

    打开Tomcat,访问http://localhost:8080/docs/config/context.html

    内容:

    Defining a context

    It is NOT recommended to place <Context> elements directly in the server.xml file. This is because it makes modifying the Context configuration more invasive since the main conf/server.xml file cannot be reloaded without restarting Tomcat.

    Individual Context elements may be explicitly defined:

    • In an individual file at /META-INF/context.xml inside the application files. Optionally (based on the Host's copyXML attribute) this may be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to application's base file name plus a ".xml" extension.
    • In individual files (with a ".xml" extension) in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory. The context path and version will be derived from the base name of the file (the file name less the .xml extension). This file will always take precedence over any context.xml file packaged in the web application's META-INF directory.
    • Inside a Host element in the main conf/server.xml.

    Default Context elements may be defined that apply to multiple web applications. Configuration for an individual web application will override anything configured in one of these defaults. Any nested elements, e.g. <Resource> elements, that are defined in a default Context will be created once for each Context to which the default applies. They will not be shared between Context elements.

    • In the $CATALINA_BASE/conf/context.xml file: the Context element information will be loaded by all webapps.
    • In the $CATALINA_BASE/conf/[enginename]/[hostname]/context.xml.default file: the Context element information will be loaded by all webapps of that host.

    With the exception of server.xml, files that define Context elements may only define a single Context element.

    In addition to explicitly specified Context elements, there are several techniques by which Context elements can be created automatically for you. See Automatic Application Deployment and User Web Applications for more information.

    To define multiple Contexts that use a single WAR file or directory, use one of the options described above for creating a Context that has a path that is not related to the base file name and create multiple Context definitions.

  • 相关阅读:
    SQL Server 与 Entity Framework 级联删除
    web api 2 学习笔记 (Odata ODataQueryOptions 使用)
    【建议收藏】设计师必备-史上最全的个人资料页面设计模板下载
    浅谈产品经理入门和学习路径
    最全面!2019年最新UX设计趋势预测合集
    最新Dashboard设计实例、技巧和资源集锦,视觉和功能两不误,妥妥的!
    【技巧分享】设计师如何向开发人员顺利交付作品?
    摹客iDoc201901-2新功能点评
    企业类Web原型制作分享-Kraftwerk
    【新年福利】2019年值得一用的8款协作工具
  • 原文地址:https://www.cnblogs.com/flying607/p/3446024.html
Copyright © 2011-2022 走看看