现象:前端传过来了一个字符串格式的时间,但后端对应的 Java 字段是 LocalDateTime 类型,Spring 框架不知道该怎么把这个特定格式的字符串转换成时间对象,于是报错了。

解决方案:给对应的字段加上注解@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss"),注意软件包是org.springframework.format.annotation的。