How to send array with Spring RestTemplate?

后端 未结 4 750
心在旅途
心在旅途 2021-01-14 06:43

How do I send array parameter with Spring RestTemplate?

This is the server side implementation:

@RequestMapping(value = \"/train\", method = RequestM         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-14 07:24

    Try this

    Change your request mapping from

    @RequestMapping(value = "/train", method = RequestMethod.GET)
    

    to

     @RequestMapping(value = "/train/{category}/{positiveDocId[]}/{negativeDocId[]}", method = RequestMethod.GET)
    

    and your URL in restTemplate

    change URl in the below given format

    http://localhost:8080/admin/train/category/1,2,3,4,5/6,7,8,9
    

提交回复
热议问题