我正在创建一个端点,它将接收日期以在服务器端进行一些过滤。代码如下所示:
@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
谢谢!