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/ ...
随机推荐
- iOS9 集成指纹解锁
添加依赖库 LocalAuthentication.framework #import <LocalAuthentication/LocalAuthentication.h> // 头文件 ...
- C语言的运行机制
目的:通过分析c语言转换成汇编代码后的执行过程对汇编语言和X86构架有一个初步认识 实验代码 1 #include <stdio.h> 2 3 int g(int x) 4 { 5 ret ...
- 学习springMVC实例1——配置和跳转到HelloWorld
本文让大家迅速掌握springMVC的使用方法,以最简单的方式理解此框架 一.用eclipse新建一个web项目,命名为springMVC1,tomcat的端口号为9090 二.在WEB-INF目录下 ...
- 跟我学android-常用控件之 TextView
TextView 是Android文本控件,用于显示文字. 我们先看一看TextView的结构(developer.android.com) 从这里我们可以得知,TextView是View的子类,他有 ...
- 文件操作-php
<?php /* 建立缓存 可以用文件长时间保存数据 文件是以liunux为模型的 在Windows下只能获取file ,dir unknow linux 下可以获取block char dir ...
- jQuery中事件的学习
刚学习了jQuery中的事件,主要通过bind(),toggle(),hover()来主要实现,下面先说一说关于bind的想关要点. 1.bind方法. bind方法的主要参数为bind(type,f ...
- php 实用函数
第一次随笔,写一些自己工作当中比较实用的函数吧. 数组函数: 1 array_column --返回数组当中指定的一列 用法一:返回数组当中指定的一列 应用场景:取出全班同学的id,去其他表查询这些同 ...
- JavaScript学习 常用的对话框函数
JavaScript提供了三个很不错的对话框函数,使用这三个函数可以很方便的显示一个对话框: 一.alert(); <script type="text/javascript" ...
- Solr4.8.0源码分析(7)之Solr SPI
Solr4.8.0源码分析(7)之Solr SPI 查看Solr源码时候会发现,每一个package都会由对应的resources. 如下图所示: 一时对这玩意好奇了,看了文档以后才发现,这个serv ...
- 基于fis的前端模块化和工程化方案
前端构建工具 面对日益复杂的前端环境以及前端技术.node技术的高速发展,前端的开发也越来越工程化,体系化,也就是出现了前端自动化构建工具.他们完成的任务目标基本是: js,css,图片的自动压缩合并 ...