I need to find an approach for below problem.
Need to configure below URLs in spring controllers
/karnataka/playgrounds
/karnataka/banglore-playgrounds
/karnataka/airport-road-banglore-playgrounds
/karnataka/chinnaswamy-stadium-airport-road-banglore
@PathVariables here are
{state} = karnataka
{city} = banglore
{locationType} = playgrounds
{location} = airport-road
{pointName} = chinnaswamy-stadium
I have these 5 variables. There can be any value for state, city, location type, location, point name (allowed values/list can be stored in properties or in db).
My question is how can I configure above mentioned URLs with these path variables in spring controllers?
Tried some request mapping but not able to set priority.
@RequestMapping(value = {"/{state}/{locationType}"})
@RequestMapping(value = {"/{state}/{city}{type}"})
@RequestMapping(value = {"/{state}/{location}-{city}-{type}"})
@RequestMapping(value = {"/{state}/{pointName}-{location}-{city}"})
Also there '-' problem. There can be '-' between two Path Variables and there can be '-' between a single variable like airport-road. So some already allowed values can be solution for this.
Please provide a solution to this.
Thanks in advance!