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?

4
  • spring only provides parameters from original request in string format at the moment. I would say no, unless you rewrite part of the core functionality Commented Apr 28, 2017 at 10:57
  • are you trying to input an array of decimals? Commented Apr 28, 2017 at 13:42
  • this may help Commented Apr 28, 2017 at 13:45
  • @SalmanKazmi yes, i'm trying to parse an array, as they do in RequestMapping, but i don't want it as endpoint. please check post i mentioned in question, thank you :) Commented Apr 28, 2017 at 14:02

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.