Map<String, String> pathVariables = (Map<String, String>) request
.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
Using above code, I was able to get the pathVariables but...
How can i get these parameters in order, as this is unordered map so it will not provide me ordered keys according to the url?
for eg: i have http://localhost:8080/url/123/234/xyz/123 which should map to http://localhost:8080/url/{id}/{deptId}/{code}/{empId}.
Now how can i know that first 123 maps to id or empId ???
I want this url path parameter in exact order so that i could map it for my usecase. Any help would be appreciated.
Actually, you can't do that easily using just servlet api. Frameworks are doing that for you, like spring web-mvc and dropwizard. You have to implement your servlet or servlets the way they can handle uris with specific structure and then extract desired path variables. That's pretty complex. I would suggest using some web framework for that or at least some library that will help you.
Good luck.