Debanjan Debanjan - 1 year ago 84
Java Question

Receive Collection/Iterable as arguments in spring boot controller

I am new to Spring and I want to write a controller which will take

as arguments. Like this:

@RequestMapping(value = "friends", method = RequestMethod.POST)
public @ResponseBody Callable<Iterable<User>>
getFriendsOfUser(@RequestParam(required = true, name = "mobiles") Iterable<String> mobs) {
// return callable

There is no compilation error, but I cannot make it work. Can you say how will this work? And how shall be the request to this api be constructed?

Answer Source
public String getFriendsOfUser(@RequestParam(required = true, value = "mobiles")  String[] mobiless){

and your mobile should be




still if you have any doubt post your front-end code and Ajax call.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download