1

I can get a map of all query params like so:

String example(@RequestParam Map<String, String> queryParams)

Is there a way to get a map of all the path variables?

Steve
  • 53,375
  • 33
  • 96
  • 141

2 Answers2

3

this should work:

String example(@PathVariable Map<String, String> pathVariables)

see http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolver.html

Biju Kunjummen
  • 49,138
  • 14
  • 112
  • 125
  • But I got error: Could not find '@PathVariable' [pathVariables] in '@RequestMapping'. Do you know why? – Joyin Jun 12 '16 at 03:05
0

See this

www.mydomain.com/order/123 --> URL

/order/{orderId} --> You want to fetch orderId

@RequestMapping(value = " /order/{orderId}", method=RequestMethod.GET) public String getOrder(@PathVariable String orderId){ //fetch order }

Also there is simple example here, Hope that helps

Thanks

Community
  • 1
  • 1
Malatesh
  • 1,944
  • 6
  • 26
  • 39