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. spring cloud系列教程第一篇-介绍

    spring cloud系列教程第一篇-介绍 前言: 现在Java招聘中最常见的是会微服务开发,微服务已经在国内火了几年了,而且也成了趋势了.那么,微服务只是指spring boot吗?当然不是了,微 ...

  2. 数据库——数据库SQL语句大全,最常用的SQL语句

    检索数据 检索单个列: SELECT pname FROM product 检索多个列: SELECT pname,market_price,is_hot FROM product 检索所有列: SE ...

  3. jQuery中的查找节点、创建节点、插入节点、删除节点、替换节点、复制节点操作方法

    jQuery操作节点我们可以分六点来讲,查找节点.创建节点.插入节点.删除节点.替换节点.复制节点. 一.查找节点 text() - 设置或返回所选元素的文本内容   ,html() - 设置或返回所 ...

  4. window下用notepad++编辑了脚本文件然后放在linux报错显示无法运行

    首先vi :set ff 查看文件类型 接着 下载dos2unix  root用户下yum -y install dos2unix 然后 dos2unix 文件.sh 转换格式  接着在正常启动即可

  5. FOC 电流采样为什么不准?你忽略了这个细节

    文章目录 1 引言 2 延迟类型及典型时间 3 延迟源详细分析 3.1PWM死区时间插入 3.2 光耦延迟和预驱动器延迟 3.3晶体管开关延迟 3.4其他延迟 4 结语 在电机驱动的FOC控制开发过程 ...

  6. YOLOV4在linux下训练自己数据集(亲测成功)

    最近推出了yolo-v4我也准备试着跑跑实验看看效果,看看大神的最新操作 这里不做打标签工作和配置cuda工作,需要的可以分别百度搜索   VOC格式数据集制作,cuda和cudnn配置 我们直接利用 ...

  7. vue mock 模拟接口数据

    日常总结 希望能帮到大家 1 mock/sever.js  //创建服务 let http=require('http') let fs=require('fs') let url=require(' ...

  8. 基于 abp vNext 和 .NET Core 开发博客项目 - 使用 abp cli 搭建项目

    首先,默认咱们已经有了.net core 3.1的开发环境,如果你没有,快去下载... https://dotnet.microsoft.com/download 由于项目是基于abp vNext开发 ...

  9. pod install update没有反应

    出去是镜像的问题,我用的是外网,所以应该不是镜像的问题, 换用这个: pod install --verbose --no-repo-update pod update --verbose --no- ...

  10. Python基础语法day_02——字符串规则

    day_02 使用方法修改字符串的大小写 将字符串首字母变成大写 >>> name = "ada lovelace" >>> print(nam ...