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\to\images"/>
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\to\images"/>
</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
Difference between Tomcat's extraResourcePaths and aliases to access an external directory--转的更多相关文章
- Tomcat 开发web项目报Illegal access: this web application instance has been stopped already. Could not load [org.apache.commons.pool.impl.CursorableLinkedList$Cursor]. 错误
开发Java web项目,在tomcat运行后报如下错误: Illegal access: this web application instance has been stopped already ...
- Tomcat启动时卡在“INFO: Deploying web application directory ”
今天在linux上的tomcat部署一个网站时,在刚启动tomcat的时候提示启动成功,然后也能访问成功. 可是第二次启动时虽然没有报错,但无法访问tomcat,查看了catalina.out日志,发 ...
- Mac系统下安装Tomcat,以及终端出现No such file or directory的错误提示解决方案
Tomcat,作为一个免费的服务器口碑实在太好,本想安装一个研究研究,无奈电脑是mac系统,在网上搜了一些安装方法总是出错,直到遇到了这篇博客,http://www.cnblogs.com/qingy ...
- 启动tomcat时,一直卡在Deploying web application directory这块的解决方案
本来今天正常往服务器上扔一个tomcat 部署一个项目的, 最后再启动tomcat 的时候 发现项目一直都访问不了,看了一下日志: [root@iz8vbdzx7y7owm488t4d89z bin] ...
- 启动tomcat时,一直卡在Deploying web application directory
本来今天正常往服务器上扔一个tomcat 部署一个项目的, 最后再启动tomcat 的时候 发现项目一直都访问不了,看了一下日志: 1 2 3 4 5 6 7 [root@iz8vbdzx7y7owm ...
- [转载]启动tomcat时,一直卡在Deploying web application directory这块的解决方案
转载:https://www.cnblogs.com/mycifeng/p/6972446.html 本来今天正常往服务器上扔一个tomcat 部署一个项目的, 最后再启动tomcat 的时候 发现项 ...
- linux启动tomcat很久或者很慢Tomcat启动时卡在“INFO: Deploying web application directory ......”的解决方法
解决方案: 找到jdk1.x.x_xx/jre/lib/security/java.security文件,在文件中找到securerandom.source这个设置项,将其改为: securerand ...
- Tomcat启动时卡在“INFO: Deploying web application directory ......”的解决方法
https://blog.csdn.net/njchenyi/article/details/46641141
- Tomcat翻译--The Host Container
原文:http://tomcat.apache.org/tomcat-7.0-doc/config/host.html Introduction(介绍) The Host element repres ...
随机推荐
- 说说RMAN里的obsolete
RMAN> report obsolete; RMAN retention policy will be applied to the commandRMAN retention policy ...
- C++拾遗(三)关于复合类型
数组相关 初始化只能在定义的时候使用,不能把数组赋给另一个数组. 初始化可以提供比元素数目少的初值,其它元素将被置为0. 字符char数组只有在以\0结尾时才是一个字符串.sizeof()返回数组的长 ...
- hdu 3371 Connect the Cities (最小生成树Prim)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3371 题目不难 稍微注意一下 要把已经建好的城市之间的花费定义为0,在用普通Prim算法就可以了:我没 ...
- Taxi Cab Scheme POJ && HDU
Online Judge Problem Set Authors Online Contests User Web Board Home Page F.A.Qs Statistical Charts ...
- python 文件系统
- 使用HTML+CSS,jQuery编写的简易计算器
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- 初涉JavaScript模式 (6) : 原型模式 【二】
原型与in操作符 有两种方式使用in操作符:单独使用和在for-in循环中使用. 在单独使用时,in操作符会遍历实例公开(可枚举)的属性,如果找到该指定属性则返回true,无论该指定属性是存在与实例中 ...
- js 超级玛丽(未完成)
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- Python几种创建list的方法的效率对比
我们用 生成一个0到((1万倍n)-1)的list做例子 首先这种方式复杂度为平方级 ''' def test1(n): lst = [] for i in range(n*10000): lst = ...
- [Python笔记]第四篇:内置函数
本篇主要内容:内置函数 函数 参考:https://docs.python.org/3.5/library/functions.html 内置函数列表 一.数学运算类 abs(x)求绝对值 >& ...