URLRewrite in Tomcat 7

前端 未结 2 800
无人共我
无人共我 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

    <rule>
        <from>/products/([0-9]+)</from>
        <to>/products/index.jsp?product_id=$1</to> 
    </rule> 
    

    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

    0 讨论(0)
  • 2021-01-13 16:18

    For Tomcat 7 you can also use tuckey . Tucket is a Java Web Filter for any compliant web application servers and allows mod_rewrite just like Apache

    0 讨论(0)
提交回复
热议问题