Thanks to help of the spring guys I was able to fix this issue.
Is pretty simple actually when you look at it. The only way to try to map something like that and knowing that PathVariable is required (the value per se) you need to have different mappings for the conbinations you need like this:
Code:
@RequestMapping(value = {"/inventory/pepe/{firstName}/{lastName}"}, method = RequestMethod.GET)
public String pepe(@PathVariable("firstName") String firstName, @PathVariable("lastName") String lastName) {
logger.info("First name: " + firstName + " Last name: " + lastName);
return "inventory/pepe";
}
@RequestMapping(value = {"/inventory/pepe/{firstName}"}, method = RequestMethod.GET)
public String pepe(@PathVariable("firstName") String firstName) {
return this.pepe(firstName, "");
}
As you can see I have a request /inventory/pepe/{firstName} which maps all the /inventory/pepe/1 or /inventory/pepe/whatever and calls the main method pepe with the double parameters. So actually you can always call the methods with the longer number of parameters (for reuse) and send default values.
If would be very weird to accept in PathVariable default values because the Mapping wouldn't make any sense at all they would be mappings like
"/inventory/pepe/{firstName}/list" would map to /inventory/pepe/list which is not right for the mapping since you are expecting actually a real path like "/inventory/pepe/david/list".
I hope this helps.
Thanks again to Mr. Poutsma for his help.