Moatez Bouhdid Moatez Bouhdid - 5 months ago 39
HTTP Question

Json List to String List : Spring mvc Controller

I want to send this List example :


To this controller :

public String addUsersToProject(@RequestBody List<String> usersIds, @PathVariable String projectTitle){..}

But I can't read the list :

Could not read document: Can not deserialize instance of java.util.ArrayList

Any suggestion will be appreciated, Thank you.


The easiest way is create wrapper class with id field as List (userIds).


class IdsWrapper {
    private List<Integer> id;

And use it in controller:

public String addUsersToProject(@RequestBody IdsWrapper ids) {...}

Also you can check link Possible maping solutions