I'm trying to pass a complex search query object to a Spring Controller, without making too much customization (like custom converters).
I know, for instance, that I can get a list / array of parameters like this:
GET http://host.com/path?param=abc¶m=123
@GetMapping
String query(String[] param) {
// param[]={abc, 123}
...
}
And if I want an object I can do this:
GET http://host.com/path?field1=abc&field2=123&field3.a=1&field3.b=2
@GetMapping
String query(MyObject obj) {
// MyObject(field1=abc, field2=123, field3=NestedObject(a=1, b=2))
...
}
class MyObject {
String field1, field2;
NestedObject field3;
}
class NestedObject {
int a, b;
}
But what I really need is to combine both:
[...]
class MyObject {
String field1, field2;
NestedObject[] field3; <--
}
[...]
How do I structure the query parameters to correctly fill the array of NestedObject
?