Can Spring MVC handle multivalue query parameter?

后端 未结 3 696
终归单人心
终归单人心 2020-11-30 08:14

Having this http://myserver/find-by-phones?phone=123&phone=345 request, is it possible to handle with something like this:

@Controller
publi         


        
3条回答
  •  悲哀的现实
    2020-11-30 08:55

    I had an issue with indexed querystring like

    http://myserver/find-by-phones?phone[0]=123&phone[1]=345
    
    and only handling with
    MultiValueMap
    worked for me. Neither List or String[] were handling it properly.

    I also tried

    @RequestParam("phones[]")
    but RequestParamMethodArgumentResolver is looking explicitly for phones[] ignoring indexes. So that is why I decided to let RequestParamMapMethodArgumentResolver handle it.

提交回复
热议问题