zoukankan      html  css  js  c++  java
  • Difference between Tomcat's extraResourcePaths and aliases to access an external directory--转

    Question:

    Simple question: In Tomcat7, what's the difference between using extraResourcePaths and aliases to access an directory outside the application?

    I can use either of these two server.xml snippets and they both seem to work. Both seem to load this URL successfully: http://localhost/app/images/box.jpg. Is there an advantage to using one over the other?

    <Context docBase="Eclipse_Project" path="/app"
            reloadable="true" source="org.eclipse.jst.j2ee.server:Eclipse_Project"
            aliases="/images=D:path	oimages"/>
    

    or

    <Context docBase="Eclipse_Project" path="/app"
            reloadable="true" source="org.eclipse.jst.j2ee.server:Eclipse_Project">
            <Resources className="org.apache.naming.resources.VirtualDirContext"
                    extraResourcePaths="/images=D:path	oimages"/>
    </Context>
    Answer:

    This is the result of having multiple different ways of pulling in resources that aren't part of a WAR or exploded directory. Frankly it is a mess long overdue a clean-up. The 'overlay' (or whatever it ends up being called) feature proposed for Servlet 3.1 (i.e. Tomcat 8) has prompted a major clean-up. All the current implementations will be unified into a single implementation. It isn't pretty though, and it is going to take a while to complete.

    Aliases are treated as external to the web application resources. The DirContext checks aliases before it checks its internal resources. Hence when you request the real path you get the original.

    If you use extraResourcePaths they are treated as part of the web application resources. It looks like Eclipse has triggered a copy of application resources to the work directory. This is usually done to avoid file locking. Since the extraResourcePaths are treated as part of the webapp, they get copied too and getRealPath() reports the copied location since that is where Tomcat is serving the resources from.



    原文地址:http://stackoverflow.com/questions/11138701/difference-between-tomcats-extraresourcepaths-and-aliases-to-access-an-external



  • 相关阅读:
    win10 IP ping不通解决
    Oracle配置远程连接,添加新的IP地址,必须保存原来的127.0.0.1,否则都不能连接
    【赵强老师】Kafka的体系架构
    【赵强老师】在Hive中使用Load语句加载数据
    【赵强老师】什么是PL/SQL?
    【赵强老师】在MongoDB中使用游标
    【赵强老师】如何分析Java的内存溢出问题
    【赵强老师】Kubernetes平台中日志收集方案
    【赵强老师】Redis的消息发布与订阅
    【赵强老师】数据库的事务
  • 原文地址:https://www.cnblogs.com/davidwang456/p/3924259.html
Copyright © 2011-2022 走看看