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,872
  • 12
  • 37
  • 51

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
  • 23,742
  • 39
  • 159
  • 250