Questions tagged «jsr310»

10
如何在Spring中使用LocalDateTime RequestParam?我得到“无法将字符串转换为LocalDateTime”
我使用Spring Boot并包含jackson-datatype-jsr310在Maven中: <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> <version>2.7.3</version> </dependency> 当我尝试使用Java 8日期/时间类型的RequestParam时, @GetMapping("/test") public Page<User> get( @RequestParam(value = "start", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime start) { //... } 并使用以下网址进行测试: /test?start=2016-10-8T00:00 我收到以下错误: { "timestamp": 1477528408379, "status": 400, "error": "Bad Request", "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", "message": "Failed to convert value of type [java.lang.String] to required …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.