3

I found THIS useful thread explaining how to use spring to extract the variables from path to the Map<String,String>. I would like to go even further and parse those variables into type using spring, but unfortunately i'm unable to do so.

format: "/mypath/[{varaible}]/something"

input: "/mypath/[0.0,0.1,0.2]/something"

output: Double[] myArray

Is it possible to use spring functionality for this?

Community
  • 1
  • 1
Martin Brisiak
  • 3,473
  • 12
  • 35
  • 49

1 Answers1

0

I think you can use this syntax (not tested, but quite sure...):

@RequestMapping("/mypath/{doubles}/something")
public String aControllerMethod(@PathVariable("doubles") Double[] arrayOfDoubles) { ... }

and executing the request this way:

/mypath/0.0,0.1,0.2/something
davioooh
  • 22,098
  • 37
  • 145
  • 234