I am trying to understand tuckey urlRewrite to write a rule
but am unable to do it.
I have a Servlet
that has URL Pattern defined @WebServlet("/user/*")
. At the load of Servlet
I get URL like http://localhost:8080/Navigation/user/*
.
How can I make a rule so whenever /user/
URL is loaded it should go to http://localhost:8080/Navigation/user/list
. I tried this:
<rule>
<from>^/user/*$</from>
<to>/user/list</to>
</rule>
but this is not working.
You can use something like this:
<urlrewrite use-context="true">
<rule>
<from>(.*)/user/(.*)$</from>
<to type="permanent-redirect">$1/user/list</to>
</rule>
</urlrewrite>
Where $1
represents anything that is before /user/
ie denoted by the first (.*)
.
A read through this manual might also help.
Hope this helps.
试着像这样给<to type="redirect">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.