I am trying to construct a clean URL mapping inside my MVC application and I found alot of common urls like:
/SITE/{city}-{language}/user/{userId}
@RequestMapping(value = "/{city}-{language}/user/{userId}",
method = RequestMethod.GET)
public String user(@PathVariable String city,
@PathVariable String language,
@PathVariable String userId,
Model model) {}
/SITE/{city}-{language}/comment/{userId}-{commentId}
@RequestMapping(value = "/{city}-{language}/comment/{userId}-{commentId}",
method = RequestMethod.GET)
public String comment(@PathVariable String city,
@PathVariable String language,
@PathVariable String userId,
@PathVariable String commentId,
Model model) {}
Is there a way to auto bind the city and the language to the model automatically instead of @PathVariable of Filters, I think it make since as it will reduce the @RequestMapping function paramets count.
I make a work around that serves my need, I created an abstract base class that maps the common params.
and now the two common attributes will be available in the model object