Question

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.

Was it helpful?

Solution

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/ i.e. denoted by the first (.*).

A read through this manual might also help.

Hope this helps.

OTHER TIPS

try giving like this <to type="redirect">

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top