Can a Tomcat docBase span multiple folders?--转
Question:
I apologize if this is a poor question, but I'm using Windows and looking to see if there's a way to run a webapp via Tomcat where the docBase is multiple folders.
A little more background is that we have our Eclipse project set up in a way that the web content is broken into separate folders. One folder represents what our SDK provides, one is a folder which has SDK patches, and a third is the project-specific components -- either of the last two folders could have subfolders/files that "erase" items from the first two.
I'd like to try and have my context file point back into my dev environment so that I don't need to build/deploy in order to see the changes I'm making. Is this possible?
A couple other notes:
- We thought about using symlinks via
mklink, but didn't want to create complexity if simplicity was out there. - This is just for running locally so simple hacks would be allowed. When we create the WAR which gets deployed to the real environment the ANT script creates a single web root.
Answer 1:
I use it this way:
<Context docBase="jquery" path="/js/jquery" />
<Context docBase="foobar/www/javascript" path="/js" />
<Context docBase="foobar/www/css" path="/css" />
<Context docBase="foobar" path="/" />
Important for the concrete context is the path-attribute. A request is processed from top to bottom.
So a request for /css/default.css is only processed from the 3rd context.
A different order may catches a different context.
This is wrong:
<Context docBase="foobar" path="/" />
<Context docBase="jquery" path="/js/jquery" />
<Context docBase="foobar/www/javascript" path="/js" />
<Context docBase="foobar/www/css" path="/css" />
Because /css/default.css will be catched by the first context, not the fourth.
Edit 2013-08-10: (Not by the answer-author) It is important to note that while the above technique will work, much of it is actually incorrect. Please see comments for details.
Answer 2:
Tomcat can do this for you, you just need a little extra configuration.
You are looking for VirtualDirContext which allows you to specify a list of extraResourcePaths which will be searched (in order) for additional files. You can use that to merge static resources, JSPs, directories of JAR files, etc.
Just remember that each path you add makes every file lookup potentially take longer -- especially if the file can't be found at all.
原文:http://stackoverflow.com/questions/17738049/can-a-tomcat-docbase-span-multiple-folders/17861223#17861223
Can a Tomcat docBase span multiple folders?--转的更多相关文章
- Could not publish server configuration for MyEclipse Tomcat v7.0. Multiple Contexts have a path
Could not publish server configuration for Tomcat v6.0 Server at localhost. 经常在使用tomcat服务器的时候 总会发生一些 ...
- tomcat docBase 和 path
<Context docBase="zjzc-web-api" path="/api" reloadable="false"/> ...
- 【Tomcat】Tomcat的使用
第一章 JDK的安装 1.1 windows下安装 1.1.1 配置环境变量 安装完成后,还要进行 Java 环境的配置,才能正常使用,步骤如下: (1)在我的电脑点击右键——〉选择属性, (2) ...
- Tomcat Clustering - A Step By Step Guide --转载
Tomcat Clustering - A Step By Step Guide Apache Tomcat is a great performer on its own, but if you'r ...
- nginx+tomcat+memcached搭建服务器集群及负载均衡
在实际项目中,由于用户的访问量很大的原因,往往需要同时开启多个服务器才能满足实际需求.但是同时开启多个服务又该怎么管理他们呢?怎样实现session共享呢?下面就来讲一讲如何使用tomcat+ngin ...
- eclipse发布项目报错:Multiple Contexts hava a path of “/xxx“
你的位置:首页 > Java编程 > eclipse发布项目报错:Multiple Contexts hava a path of “/xxx“ eclipse发布项目报错:Multipl ...
- Nginx 与Tomcat 实现动静态分离、负载均衡
Nginx 与Tomcat 实现动静态分离.负载均衡 一.Nginx简介: Nginx一个高性能的HTTP和反向代理服务器, 具有很高的稳定性和支持热部署.模块扩展也很容易.当遇到访问的峰值,或者有人 ...
- Nginx+Tomcat+Memcached 实现集群部署时Session共享
Nginx+Tomcat+Memcached 实现集群部署时Session共享 一.简介 我们系统经常要保存用户登录信息,有Cookie和Session机制,Cookie客户端保存用户信息,Sessi ...
- GridLayout with span
Widgets can span multiple columns or rows in a grid. In the next example we illustrate this. #!/usr/ ...
随机推荐
- 【USACO 1.4.4】母亲的牛奶
[题目描述] 农民约翰有三个容量分别是A,B,C升的桶,A,B,C分别是三个从1到20的整数, 最初,A和B桶都是空的,而C桶是装满牛奶的.有时,约翰把牛奶从一个桶倒到另一个桶中,直到被灌桶装满或原 ...
- chrome浏览器调试
我们在开发前端代码的时候经常会遇到要调试css,js代码的时候,以前在调试的时候可能需要修改了css代码,然后在前台看一下样式,js也是一样的,可能会用alert或者是console.log输出,然后 ...
- WebForm,Winfrom下拉框添加全部行
WebForm: dropPostalLineNo.DataSource = "数据源"; dropPostalLineNo.DataTextField = &quo ...
- 常用排序算法总结(C#版)
首先,说说几个排序中的概念. 1.稳定排序和非稳定排序 简单地说就是所有相等的数经过某种排序方法后,仍能保持它们在排序之前的相对次序,我们就说这种排序方法是稳定的.反之,就是非稳定的. 比如:一组数 ...
- history对象属性和方法
history对象保存着用户上网的历史记录,从窗口被打开的那一刻算起,history是window对象的属性,因此每个浏览器窗口.每个标签页乃至每个框架,都有自 己的history对象和特定的wind ...
- jquery ajax (2)实例 .GET
1js 代码 $(function(){ $("#send").click(function(){ $.get("get3.php", { username : ...
- C语言指针类型 强制转换
关于C语言指针类型 强制转换 引用一篇文章: C语言中,任何一个变量都必须占有一个地址,而这个地址空间内的0-1代码就是这个变量的值.不同的数据类型占有的空间大小不一,但是他们都必须有个地址,而这个 ...
- 运维小东西:每天备份sql到远程服务器上
首先两台服务器可以无密码登录(这个方式比较简单,当然安全系数会降低) #ssh-keygen -t rsa #生成密钥发送给远程服务器上 #ssh-copy-id ~/root/id_rsa.pub ...
- JAVA基础(1)之hashCode()
JAVA基础(1)之hashCode() 看到一篇关于hashCode的文章(),写的很详细明白,瞬间有种恍然大悟的感觉,所以特地转过来.原文:http://blog.csdn.net/fenglib ...
- UGUI穿透3D世界判断&&UGUI全事件监听
public bool isPointUI(){ PointerEventData eventDataCurrnt = new PointerEventData (EventSystem.curren ...