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;
  • 相关阅读:
    C#static
    Sql中CHARINDEX用法
    分分钟用上C#中的委托和事件
    为什么使用抽象类?有什么好处?
    【NOIP】普及组2009 细胞分裂
    【VIJOS】P1512 SuperBrother打鼹鼠
    【NOIP】提高组2014
    @NOIP2018
    @NOIP2018
    @NOIP2018
  • 原文地址:https://www.cnblogs.com/Tpf386/p/11061566.html
Copyright © 2011-2022 走看看