I'm comming from the .net world, where if you have an argument like a Dictionary<string,List<string>> foo
in the query string, you can do something like foo[one][0]=OneZero,foo[two][0]=TwoZero,foo[two][1]=TwoOne
etc. I'd like to have the same in Java Spring (springboot).
I guess the data-type I'm looking for would be either HashMap<String,HashSet<String>>
or Map<String,Set<String>>
. However I was unable to find a proper solution for this problem. I did managed to make List<String> foo
work with foo=one&foo=two
or foo=one,two
but it seems that using a Map
as an argument is unsupported. Is my understanding correct? Is there no out of the box solution for using Maps/Dictionaries (let alone nested ones) as request parameters?
Code
@RestController
public class MyController {
@GetMapping(value = "/search")
public PLPResponse getStuff(@RequestParam Optional<String> name, @RequestParam Optional<Map<String,Set<String>> foo, HttpServletRequest request) {
//magic happens here
}
}