I need to pass list of beans into my controller.
@RestController
@RequestMapping("/api")
public class MyController {
@RequestMapping(value = "/my/{id}/method", method = RequestMethod.POST)
public Result editRequest(
@RequestParam("first") String first,
@RequestParam("second") String second,
@RequestParam("third") String third,
@RequestParam("items") List<MyBean> items,
@PathVariable("id") Long id
) {
...
}
}
And MyBean:
public class MyBean {
private Integer fst;
private String snd;
private Long thd;
private Integer fo;
public MyBean() {
}
... get/set
}
I need to do it from AngularJS, but now I'm testing it in bash with curl. What command do I need?
curl --data "first=-11374862&second=-1000&third=61&items[0][fst]=124231664&items[0][snd]=12&items[0][thd]=123&items[0][fo]=null" http://localhost:8080/api/my/100000/method --header "Content-Type:application/x-www-form-urlencoded"
Will produce error like this:
Required List parameter 'items' is not present