My question is almost 1:1 as this one. The only difference (and struggle) I have is that my "data container" has a collection of objects. It looks like this:
public class A {
    int plainFieldA;
    B fieldB;
    List<B> collectionB = new ArrayList<>();
}
public class B {
    int plainFieldB;
}
@Transactional(readOnly = true)
@GetMapping("")
public Entity getAll(A reqParam) {
    return getAll(reqParam);
}
Is it possible to define collectionB in params of the url http://localhost/api/test?plainFieldA=1 without creating a converter ? @GameSalutes correctly pointed out that since spring 4 we can do fieldB.plainFieldB=2 so the url will be: http://localhost/api/test?plainFieldA=1&fieldB.plainFieldB=2 but the question is can we do soemthing similar with collectionB without creating a converter ?
Yes, you can make the request like this:
http://localhost/api/test?plainFieldA=1&fieldB.plainFieldB=2&collectionB[0].plainFieldB=9
Or encoding the request, for postman:
http://localhost/api/test?plainFieldA=1&fieldB.plainFieldB=2&collectionB%5B0%5D.plainFieldB=9
With two objects in request:
http://localhost/api/test?plainFieldA=1&fieldB.plainFieldB=2&collectionB%5B0%5D.plainFieldB=9&collectionB%5B1%5D.plainFieldB=11
The result with breakpoint in the IDE:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With