URL Mapping

1

When accessing a user's profile, I'll pass the user's name as a parameter.

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

I would like to access it as follows

www.site.com.br/nomedousuario

Does anyone have the light of the end of the tunnel to help me?

    
asked by anonymous 18.09.2016 / 19:35

1 answer

0

You can use a Servlet filter ( link ), which will take the http request, interpret and convert it into 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.

    
18.09.2016 / 22:30