Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'

首先这个错误的意思是 前台页面传递在string类型的时间数据,比如'2020-05-31 10:00:00' 后台使用Date类型去接收,但是报错了。

解决方法:

要解决这个问题其实很简单, 在接收的字段上面,添加下面的注解 就可以了

@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") //返回时间类型

@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") //接收时间类型

private Date startTime;

注解解释:

@DateTimeFormat

该注解自动会解析处理,会把字符串类型 按照格式yyyy-MM-dd HH:mm:ss 转换成时间类型

@JsonFormat

这个注解是spring里面controller返回到页面的的转换. 把时间类型 转换成JSON格式类型,

前提取出进行展示.

完美解决报错Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'的更多相关文章

  1. 解决spring mvc 上传报错,Field [] isn't an enum value,Failed to convert value of type 'java.lang.String[]' to required type '

    没有选择附件,但是点击上传按钮的时候会报错. 之前不选择文件,直接上传空文件是可以的,后来不知道改了什么就不行了. 错误信息: -- :: [http--] TRACE org.springframe ...

  2. 【spring mvc】后台API查询接口,get请求,后台Date字段接收前台String类型的时间,报错default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'createDate';

    后台API查询接口,get请求,后台Date字段接收前台String类型的时间筛选条件 后台接口接收 使用的实体 而createDate字段在后台实体中是Date类型 报错信息: org.spring ...

  3. Failed to convert value of type 'java.lang.String' to required type 'java.time.LocalDate';

    springboot jdbc查询使用LocalDate报:Failed to convert value of type 'java.lang.String' to required type 'j ...

  4. SpringBoot 项目启动 Failed to convert value of type 'java.lang.String' to required type 'cn.com.goldenwater.dcproj.dao.TacPageOfficePblmListDao';

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tac ...

  5. spring mvc出现 Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'endtime'

    在使用spring mvc中,绑定页面传递时间字符串数据给Date类型是出错: Failed to convert property value of type [java.lang.String] ...

  6. Java 异常 Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date'

    查询时发送给服务器的日期的字符串格式:yyyy-MM-dd HH:mm:ss 服务器接收到日期的字符串之后,向 MySQL 数据库发起查询时,因为没有指定日期时间格式,导致字符串数据不能正确地转换为日 ...

  7. Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'xxx': no matching editors or conversion strategy found

    今天在完成项目的时候遇到了下面的异常信息: 04-Aug-2014 15:49:27.894 SEVERE [http-apr-8080-exec-5] org.apache.catalina.cor ...

  8. Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFa ...

  9. Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date'

    我的情况是:在applicationContext.xml文件中配置 <bean id="member" class="com.entity.Member" ...

随机推荐

  1. Web 组态运用之用户数据 ARPU 分析图

    前言 作为企业的发展,通过运营的有效管理,增加收入.降低成本,取得更好的经济效益,是核心所在,在电信企业同样如此.电信企业的利润大体上是由业务收入和成本决定的,而收入和成本又可进一步分别分解表达为不同 ...

  2. Java模拟UDP通信

    目录 Java基础:模拟UDP通信 1.一次发送,一次接收 1.1.发送方 1.2.接收方 2.多次发送,多次接收 2.1.发送方 2.2.接收方 3.模拟双方通信 3.1.发送方的线程 3.2.接收 ...

  3. 记一次jackson序列化Boolean的坑

    @Data public class CouponTemplateDto { /** * 优惠券类型id */ private Long couponTypeId; /** * 优惠券模板id */ ...

  4. 基于C语言的Q格式使用详解

    用过DSP的应该都知道Q格式吧: 目录 1 前言 2 Q数据的表示 2.1 范围和精度 2.2 推导 3 Q数据的运算 3.1 0x7FFF 3.2 0x8000 3.3 加法 3.4 减法 3.5 ...

  5. Linux dts 设备树详解(二) 动手编写设备树dts

    Linux dts 设备树详解(一) 基础知识 Linux dts 设备树详解(二) 动手编写设备树dts 文章目录 前言 硬件结构 设备树dts文件 前言 在简单了解概念之后,我们可以开始尝试写一个 ...

  6. 24款WordPress网站AI插件大盘点

    ------------恢复内容开始------------ 你想把AI(人工智能)技术和机器学习技术添加到自己的WordPress网站吗?本文中,我会分享24个利用AI技术和机器学习技术的WordP ...

  7. python 基础知识6-文件操作

    1.只读文件 #以文本打开文件'r' f = open('C:\\Users\\Administrator\\Desktop\\Python\\f.txt',mode='r',encoding='ut ...

  8. sqli-labs之Page-3

    第三十八关:堆叠注入 $sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1"; /* execute multi query */ ...

  9. RunLoop总结

    参考学习了YY大神的http://blog.ibireme.com/2015/05/18/runloop/#mode RunLoop: 看做是一个对象,这个对象管理了其需要处理的事件和消息,并提供了一 ...

  10. python--集合和文件基本操作

    集合 # 集合天生就能去重,集合也是无序的  集合也是{ }  但是空集合定义特殊s=set()  #空集合s2 = set('1234445566778')print(s2) s3 = {'1',' ...