Bind Path variables to a custom model object in spring

Spring MVC offers the ability to bind request params and path variables into a JavaBean, which in your case is Venue.
For example:

@RequestMapping(value = "/venue/{city}/{place}", method = "GET")
public String getVenueDetails(Venue venue, Model model) {
    // venue object will be automatically populated with city and place
}

Note that your JavaBean has to have city and place properties for it to work.

For more information, you can take a look at the withParamGroup() example from spring-projects/spring-mvc-showcase

Leave a Comment

tech