tomcat中的过滤器
我面临着一项任务,将依赖的 jar 应用程序添加到现有的应用程序中。现有的并没有使用太多的区域设置优势等,但我的新的应该可以。
就像我现在一样:localhost:8080/old-app
我还想拥有: localhost:8080/[en|fr|...]/new-module
谁能给我指出方向,因为即使我认为我明白了过滤器的想法,过滤器-映射,我无法解决它。
我想保留旧的,同时也想使用新的。
I am facing a task to add a dependent jar application to an existing one. The existing one does not use to much of locale benefits and so on, but my new one should.
So like I have now: localhost:8080/old-app
I want to have also: localhost:8080/[en|fr|...]/new-module
Could anyone point me the direction, because even if I think I get the idea of filters, filter-mapping, I cannot manage to solve it.
I would like to keep the old one and also have access to the new one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
new-module
部署为ROOT.war
(或将/META-INF/context.xml
中的path
设置为<代码>/)。使用 Tuckey 的URLRewriteFilter
重写特定网址并将语言部分转换为请求参数,以便可以通过request.getParameter()
使用。它与 Apache HTTPD 的mod_rewrite
非常相似。URLRewriteFilter
的替代方法是自行开发一个自定义过滤器,其功能类似于doFilter()
方法中的以下内容。将其映射到
/*
的url-pattern
上。该语言将通过转发资源上的request.getAttribute("language")
获得。Deploy
new-module
asROOT.war
(or setpath
in/META-INF/context.xml
to/
). Use Tuckey'sURLRewriteFilter
to rewrite specific URL's and transform the language part to a request parameter so that it's available byrequest.getParameter()
. It's much similar to Apache HTTPD'smod_rewrite
.An alternative to
URLRewriteFilter
is to homegrow a custom filter which does like the following indoFilter()
method.Map this on an
url-pattern
of/*
. The language will be available byrequest.getAttribute("language")
on the forwarded resource.如果您不希望应用程序名称作为上下文根,例如 localhost:8080/appname 但直接在 / 下,则必须将其放入 tomcat/webapps/ROOT 文件夹中。要获得更复杂的 URL 映射,请查看 http://ocpsoft.com/prettyfaces/
If you dont want the applications name as context root e.g. localhost:8080/appname but under / directly you have to put it into the
tomcat/webapps/ROOT
folder. To get more sophisticated URL mappings working have a look at http://ocpsoft.com/prettyfaces/