Tomcat/Java 是否有 url 重写引擎?
我们如何为 Tomcat/Java 提供 URL 重写支持?
mod_rewrite 为 Apache 提供了此功能,甚至可以在 URL 到达处理程序(例如 PHP)之前对其进行修改。 Java/Tomcat中有类似的工具吗?
更具体地说,我们需要进行修改,例如,
http://www.somedomain.com/person/1 Maps to http://www.somedomain.com/details?personId=1
这对于 servlet 代码应该是透明的,即我们应该能够在 servlet 中访问 request.getParameter("personId") 并获取 personId (1在这种情况下)。
你遇到过这样的场景吗? 你用了什么工具?
很想听听您的建议。
How can we provide URL-Rewriting support for Tomcat/Java ?
mod_rewrite provides this functionality for Apache and can modify URLs even before they reach the handler (e.g. PHP). Is there a similar tool in Java/Tomcat ?
To be more specific we need modifications such as
http://www.somedomain.com/person/1 Maps to http://www.somedomain.com/details?personId=1
And this should be transparent to the servlet code, i.e. we should be able to access request.getParameter("personId")
in the servlet and get the personId (1 in this case).
Did you come across such a scenario ? What tool did you use ?
Would love to hear your suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅 URLRewriteFilter
See the URLRewriteFilter
我确实遇到过这种情况,但为了简单起见,我使用 Apache+mod_rewrite 来前端 Tomcat。 此外,根据您的用例,使用 Apache HTTPd 进行前端还有其他优势。
I did run into this scenario but went with front-ending my Tomcat with Apache+mod_rewrite, to keep it simple. Besides there are other advantages of front-ending with Apache HTTPd depending on your use case.