• 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;
  • 相关阅读:
    蛇形填数
    开灯问题
    水仙花数
    C++Primer笔记-----day02
    C++Primer笔记-----day01
    面试智力题
    maven 打包197
    子系统 安装vsftpd197
    office 安装破解197
    oracle 创建多个数据库197
  • 原文地址:https://www.cnblogs.com/Tpf386/p/11061566.html
Copyright © 2020-2023  润新知