URL mapping

Asked

Viewed 197 times

1

When accessing a user’s profile, I pass their user name as a parameter.

www.site.com.br/busca?usuario=nomedousuario

I would like to access as follows

www.site.com.br/nomedousuario

Someone has the tunnel’s end light to help me?

1 answer

0

You can use a Servlet filter (http://tuckey.org/urlrewrite/), which will take the http request, interpret and convert to a new url. The installation is simple, just add the urlrewritefilter-4.0.3.jar file in WEB-INF/lib. In web.xml you add the following:

    <filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

I suggest you read their documentation as well.

  • Welcome to the @Jonathan community, it would be interesting to make a compilation of the article and put it here, because if the link goes off the air will no longer have the solution here.

  • Thanks marco, I’ll do it

  • And the configuration file, urlrewrite.xml, Don’t need it? What will the URL rewrite pattern look like with only the filter?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.