URLRewrite in Tomcat 7

前端 未结 2 802
无人共我
无人共我 2021-01-13 15:45

I am planning to develop an Intranet application (Java client, JSP, SQLite)

Goal of this is that when a user clicks on the link, if the user has access (to a team wh

2条回答
  •  时光说笑
    2021-01-13 16:05

    I would recommend to do it with Apache HTTP Server or another server. But if you want to do it only with Tomcat 7 use Tuckey UrlRewriteFilter:

    A Java Web Filter for any compliant web application servers (such as Tomcat, JBoss, Jetty or Resin), which allows you to rewrite URLs before they get to your code. It is a very powerful tool just like Apache's mod_rewrite.

    This filter allows you to define rules like:

    Clean a url

    
        /products/([0-9]+)
        /products/index.jsp?product_id=$1 
     
    

    eg, /products/1234 will be passed on to /products/index.jsp?product_id=1234 without the user noticing

    from Tuckey urlrewrite example

    Since Tomcat 8 you can use the rewrite valve.

    The rewrite valve implements URL rewrite functionality in a way that is very similar to mod_rewrite from Apache HTTP Server.

    Rewrite Valve docs

提交回复
热议问题