Tomcat/Java 是否有 url 重写引擎?

发布于 2024-07-24 02:50:31 字数 523 浏览 7 评论 0原文

我们如何为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷弦 2024-07-31 02:50:31

我确实遇到过这种情况,但为了简单起见,我使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文