zoukankan      html  css  js  c++  java
  • springboot自动装备date类型报错问题

    错误消息:

    Field error in object 'user' on field 'birthday': rejected value [2001-02-14]; codes [typeMismatch.user.birthday,typeMismatch.birthday,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.birthday,birthday]; arguments []; default message [birthday]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'birthday'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.util.Date] for value '2001-02-14'; nested exception is java.lang.IllegalArgumentException]]

    可以在实体类上加上注解解决无法自动转换的问题。

     代码示例:

    @DateTimeFormat( pattern = "yyyy-MM-dd")
        private Date birthday;
  • 相关阅读:
    Linux设备管理(一):kobject, kset, ktype分析
    Keepalived高可用集群
    Nginx反向代理与负载均衡
    LNMP环境应用实践
    HTTP协议
    Nginx详解
    MySQL进阶
    MySQL安装与基本使用
    Jumpserver跳板机
    PXE自动化装机
  • 原文地址:https://www.cnblogs.com/Tpf386/p/11061566.html
Copyright © 2011-2022 走看看