Use Tucky UrlRewriteFilter to hide .jsp at the end of urls

梦想的初衷 提交于 2019-12-13 15:28:11

问题


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

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