Using spring @PathVariable to retrieve and parse parameters

I found THIS helpful thread explaining how to use spring to retrieve variables from a path in Map<String,String>

. I would like to go even further and strip these variables by type using spring, but unfortunately I cannot do that.

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

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

output: Double[] myArray

Can a spring function be used for this?

+3


source to share


1 answer


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

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

      



and running the query like this:

/mypath/0.0,0.1,0.2/something

      

0


source







All Articles