Is there a url rewriting engine for Tomcat/Java?

Deadly 提交于 2019-12-17 06:36:30

问题


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.


回答1:


See the URLRewriteFilter




回答2:


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.



来源:https://stackoverflow.com/questions/950497/is-there-a-url-rewriting-engine-for-tomcat-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!