How come this code just works? I didn't specify any custom converter or annotation (like @RequestBody or @ModelAttribute) before argument ? Request is filled correctly from this GET call:
http://localhost:8080/WS/foo?token=C124EBD7-D9A5-4E21-9C0F-3402A1EE5E9B&lastSync=2001-01-01T00:00:00&pageNo=1
Code:
@RestController
@RequestMapping(value = "/foo")
public class FooController {
@RequestMapping(method = RequestMethod.GET)
public Result<Foo> excursions(Request request) {
// ...
}
}
Request is just POJO with getters and setters. I use it to shorten argument code because plenty methods uses those same arguments ...
public class Request {
private String token;
@DateTimeFormat(pattern = IsoDateTime.DATETIME)
private Date lastSync;
private Integer pageNo;
// getters and setters
}
This was my original method before introducing Request.
@RestController
@RequestMapping(value = "/foo")
public class FooController {
@RequestMapping(method = RequestMethod.GET)
public Result<Foo> excursions(@RequestParam String token, @RequestParam @DateTimeFormat(pattern = IsoDateTime.DATETIME) Date lastSync, @RequestParam Integer pageNo) {
// ...
}
}