记录一下springboot封装前台接口localdatetime

本文记录了在SpringBoot项目中,当前端传递日期时间字符串“2021-04-12 12:00:00”给后台Localdatetime字段时遇到的解析错误问题。尝试使用@DateTimeFormat注解未解决问题。解决办法是创建一个配置类以正确处理此类接口。
摘要由CSDN通过智能技术生成

记录一下springboot封装前台接口localdatetime

在公司做项目的时候发现前台传字符串“2021-04-12 12:00:00”字符串时,后台使用localdatetime接收,报错


org.springframework.http.converter.HttpMessageNotReadableException: Invalid JSON input: Cannot deserialize value of type `java.time.LocalDateTime` from String "2020-05-04 00:00": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2020-05-04 00:00' could not be parsed at index 10; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.LocalDateTime` from String "2020-05-04 00:00": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2020-05-04 00:00' could not be parsed at index 10

// 省略部分异常信息

Caused by: java.time.format.DateTimeParseException: Text '2020-05-04 00:00' could not be parsed at index 10
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值