我正在创建一个接收日期并在服务器端进行一些筛选的终端。代码如下:
@RequestMapping(
value = "/test",
method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}
)
@ResponseStatus(HttpStatus.OK)
public TestSummaryModel getTestSummaryByDate(
@RequestParam ZonedDateTime start,
@RequestParam ZonedDateTime end) {
return testService.getTestBetween(start, end);
}
当我尝试调用我的端点时,我收到一个HTTP 400错误提示:“客户端发送的请求在语法上不正确。” 我已经尝试了不同的日期格式,但没有一个有效。我是否遗漏了什么?我阅读了@DateTimeFormat,但即使我添加了它,也不起作用。@RequestParam @DateTimeFormat(pattern = "dd-MM-yyyy") ZonedDateTime start
这是我所发出请求的一个示例:
http://host/test-api/v1/test-summary/test?start=09-09-2015&end=09-09-2015
谢谢!