I have a simple @RestController
service that takes query parameters, and spring automatically parses them to an bean
:
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/rest", method = RequestMethod.GET)
public MyDTO getGiataHotel(@Valid MyParams p) {
Sysout(p.getId()); //prints "123"
}
public class MyParams {
private int id;
//private SubParams subs;
}
Query: .../rest?id=123
Now I'd like to structure the parameter object with nested classes. How can I achieve this?
public class SubParams {
private String name;
//some more
}
Ideally my query should be: Query: .../rest?id=123&name=test
, and the "test" string should go into the SubParams
bean.
Is that possible?