我正在尝试编写一个将 Java 8 Instant 作为请求参数的 Spring MVC GET 控制器:
@GetMapping
@JsonView(OrderListing.class)
@Validated
public WebSeekPaginatedResultsDto<OrderListingDto> findAll(@Valid OrderSearchCommand orderSearchCommand) {
// Some code
}
和:
public class OrderSearchCommand {
private Instant dateCreatedStart;
private Instant dateCreatedEnd;
// Some other fields
}
我正在从一些 React/Javascript 代码触发 GET 请求,如下所示:
http://localhost:8080/mms/front/orders?dateCreatedStart=2017-05-31T22%3A00%3A00.000Z
Spring 似乎不喜欢它并抛出错误。这是错误消息:
Failed to convert property value of type 'java.lang.String' to required type 'java.time.Instant' for property 'dateCreatedStart';
nested exception is java.lang.IllegalStateException:
Cannot convert value of type 'java.lang.String' to required type 'java.time.Instant' for property 'dateCreatedStart': no matching editors or conversion strategy found
知道为什么我会得到这个吗?
谢谢