前端日期选择器传了"releaseTime":"2022-4-26"给后端,然后出现这个错误
2022-04-26 16:04:31.897 WARN 8364 --- [nio-7070-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String "2022-4-26": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2022-4-26' could not be parsed at index 5; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.LocalDateTime` from String "2022-4-26": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2022-4-26' could not be parsed at index 5<EOL> at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 4, column: 19] (through reference chain: com.example.wy.entity.Notice["releaseTime"])]
{
"timestamp": "2022-04-26T08:04:31.905+00:00",
"status": 400,
"error": "Bad Request",
"path": "/notice"
}
之后查找方案加过注解@JsonFormat(pattern = "yyyy-MM-dd")
但是还是没有用,有什么办法解决嘛