是否可以在 Tomcat 中由多个上下文路径提供一个 appBase? [英] Is it possible to have one appBase served by multiple context paths in Tomcat?

查看:31
本文介绍了是否可以在 Tomcat 中由多个上下文路径提供一个 appBase?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Tomcat 中通过多个上下文路径提供一个 appBase?

Is it possible to have one appBase served up by multiple context paths in Tomcat?

我有一个最近替换了第二个应用程序库的应用程序库.我的问题是许多用户仍在访问旧上下文.我想从单个 appBase 为现在通用的应用程序提供服务,但可以通过任一上下文访问.我在低洼的水果上摇摆不定,并在webapps"目录中使用了一个符号链接……将旧的上下文路径指向新的上下文路径;它有效,但感觉俗气".而且我不喜欢为两个上下文创建数据库连接池(我想最小化连接到数据库的资源).

I have an application base that recently replaced a second application base. My problem is a number of users still access the old context. I would like to serve the, now common, application from a single appBase yet accessed via either context. I took a swing at the low lying fruit and used a symbolic link in the 'webapps' directory... pointing the old context path at the new context path; it works, but feels "cheezy." And I don't like that a database connection pool is created for both contexts ( I would like to minimize the resources for connecting to the database ).

无论如何,如果有人知道这样做的正确"方法,我将不胜感激.我使用的是 Tomcat 6.0.16 - 没有 apache 前端(我想 URL 重写会很好).

Anyway, if anyone knows of the "proper" way to do this I will greatly appreciate it. I'm using Tomcat 6.0.16 - no apache front end ( I suppose URL rewrite would be nice ).

推荐答案

我不确定上面的答案是否会阻止您的 web 应用程序加载两次(因为您必须将其部署到新旧上下文路径),但我可能弄错了.另一种选择是在旧上下文中保留一个非常简单的 web 应用程序,除了在 web.xml 中声明一个自定义 servlet 过滤器将所有请求重新写入新路径(本质上模拟 apache 的重写规则行为)之外,什么都不做.您必须自己编写过滤器类,但这很简单.

I'm not sure if the answer above will prevent your webapp from loading twice (as you'd have to deploy it to both new and old context paths), but I could be mistaken. Another option would be to have an extremely simple webapp left in the old context, that does nothing except have one custom servlet filter declared in the web.xml that re-writes all requests to the new path (essentially simulating apache's rewrite rule behaviour). You'd have to write the filter class yourself but it would be quite trivial.

这篇关于是否可以在 Tomcat 中由多个上下文路径提供一个 appBase?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆