问题
I would like to simple hide the .jsp file extension at the end of all my urls for my Java web app. I've already gotten Tucky UrlRewriteFilter integrated using Maven, but I cannot figure out the magic rule to do what I need.
For example:
example.com/webapp/home --> example.com/webapp/home.jsp
example.com/home --> example.com/home.jsp
example.com/blah --> example.com/blah.jsp
Does anyone know the trick? I've googled, read the docs, and tried several rules without luck. Thanks!
回答1:
Try this:
<rule>
<from>^/?([a-z]+)$</from>
<to type="forward">/$1.jsp</to>
</rule>
You canl additional make redirect from example.com/home.jsp to the example.com/home
回答2:
<rule>
<from>^/bookmark-new$</from>
<to>/bookmark-new.jsp</to>
</rule>
来源:https://stackoverflow.com/questions/16267454/use-tucky-urlrewritefilter-to-hide-jsp-at-the-end-of-urls