springMVC action接收参数:

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'projectStep' on field 'createDate': rejected value [2016-6-23]; codes [typeMismatch.projectStep.createDate,typeMismatch.createDate,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [projectStep.createDate,createDate]; arguments []; default message [createDate]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'createDate'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @javax.persistence.Column java.util.Date for value '2016-6-23'; nested exception is java.lang.IllegalArgumentException]

解决办法:

在action中添加方法如下,初始化属性.

@InitBinder
    protected void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    }

前台传参数时间类型不匹配:type 'java.lang.String' to required type 'java.util.Date' for property 'createDate'的更多相关文章

  1. 【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 ...

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

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

  3. 完美解决报错Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'

    Failed to convert value of type 'java.lang.String' to required type 'java.util.Date' 首先这个错误的意思是 前台页面 ...

  4. 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] ...

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

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

  6. 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 ...

  7. 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 ...

  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. 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 ...

随机推荐

  1. flash拖动条移出flash无法拖动

    原因:flash拖动条的拖动事件被嵌入flash的div的鼠标事件给截获了!

  2. 第十周PSP

    第十周PSP   工作周期:11.17-11.24  本周PSP: C类型 C内容 S开始时间 ST结束时间 I中断时间 T净时间(分) 文档 写随笔(PSP) 16:20min 16:50min 0 ...

  3. python 模拟登录--day1

    ---------------edit-in-windows-by-pycharm---------------------import randomuname = "mologa" ...

  4. slim框架中防止crsf攻击时,用到的函数hash_equals

    1.防止crsf攻击的最多解决方案就是 为每个请求生成一个唯一 token ,验证来源于客户端 HTML 表单产生的 POST等请求 . 2.这个token默认放在session中. slim框架源码 ...

  5. [转] AIX lv 4k偏移量

    转自:http://www.aixchina.net/Question/29969 前几天在客户数据库做巡检的时候,在警告日志中发现有如下警告:引用WARNING: You are creating ...

  6. 修复IE9.0下PlaceHolder 属性问题js脚本

    在开发前端系统时候碰到这种兼容问题,以下是个人解决方案,希望能给其他人带来帮助: var JPlaceHolder = { //检测 _check: function () { return 'pla ...

  7. 十分钟使用github pages +hexo拥有个人博客

    最近想自己搭建自己的个人博客,毕竟这样觉得比较geek,但是搜了资料,感觉良莠不齐,好多东西说的含糊不清,于是自己记录下自己的搭建过程. 1, 安装nodejs 2, 安装git 3, 申请githu ...

  8. IIS发布WCF服务项目之本地

    最近由于项目需求,要做一个上传文件附件的功能,由于是多用户访问,所以这就用到了WCF服务,程序编写完成就需要发布了, 下面记录下发布到IIS的过程: 1,安装IIS 第一步:检查Windows7中II ...

  9. win7 部署WCF遇到的问题记录

    1. IIS7 handler Mappings默认没有*.svc 的处理,需要安装(页面错误提示好像会提示缺少相应的处理器,记不清楚了) 方法:使用 ServiceModelReg.exe 工具 路 ...

  10. 如何用Tacker将NFV带入OpenStack?

    最初社区里很多人争论过NFV是否属于OpenStack,而后来可以确定的是OpenStack的确占据了NFV会话中的很大一部分,并且形象地反映在了下面的ETSI MANO概念架构图中,OpenStac ...