I'm going to use the StackOverflow's user profile's page as an example. Let's say we have this URL:
https://stackoverflow.com/users/2036414/userlogin
If we change (edit in the browser's url bar) the last path variable like this:
https://stackoverflow.com/users/2036414/aWordThatIsNotTheLoginOfThisUser
...and push Enter, the URL returned will be the first, what means that this variable is being setted to the right login, based on the other variable, which is probably the id of the user (2036414). In other words, the URL is corrected to:
https://stackoverflow.com/users/2036414/userlogin
My question is: how to do that using Spring MVC? Here's my controller:
@RequestMapping(value="/{id}/{login}", method = RequestMethod.GET)
public String showPerfilUsuario(@PathVariable("id") long id, @PathVariable("login") String login, Map<String, Object> model){
Usuario usuario = usuarioService.buscarUsuarioPorId(id);
model.put("usuario", usuario);
return "usuario"; //that's the tiles definition's name
}
Any help will be apreciated, thanks.