文章首发于个人博客,欢迎访问关注:https://www.lin2j.tech

GET 请求中的日期参数在使用 @JsonFormat 格式化时间后报错

@ApiModelProperty("发布时间-开始")
@JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN,timezone = Constants.GMT8)
private Date startPublishTime;
org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'algoInfoQo' on field 'startPublishTime': rejected value [2021-03-29]; codes [typeMismatch.algoInfoQo.startPublishTime,typeMismatch.startPublishTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [algoInfoQo.startPublishTime,startPublishTime]; arguments []; default message [startPublishTime]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'startPublishTime'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@io.swagger.annotations.ApiModelProperty @com.alibaba.fastjson.annotation.JSONField java.util.Date] for value '2021-03-29'; nested exception is java.lang.IllegalArgumentException]at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:164) ~[spring-web-5.1.8.RELEASE.jar:5.1.8.RELEASE]

增加 @DateTimeFormat 标注即可。

@ApiModelProperty("发布时间-开始")
@DateTimeFormat(pattern = DatePattern.NORM_DATE_PATTERN, iso = DateTimeFormat.ISO.DATE)
@JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN,timezone = Constants.GMT8)
private Date startPublishTime;

Field error in object ‘xxx‘ on field ‘xxx‘: rejected value [xxx]相关推荐

  1. Field error in object ** on field **

    错误信息: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindi ...

  2. springboot使用junit单元测试是发生报错 Field taskUtils in com.xxx.xxx.xxxx.xxx required a bean of type 'xxx.xxx.

    使用junit单元测试mybatis时发生如下错误 Error starting ApplicationContext. To display the conditions report re-run ...

  3. springboot踩坑日记——Field xxx.xxx.xxx required a bean of type 'xxx.xxx.xxx' that could not be found

    使用feign时报创建的feign接口找不到 Field xxx.xxx.xxx required a bean of type 'xxx.xxx.xxx' that could not be fou ...

  4. 使用Feign服务远程调用项目启动时报错:Field xxx in xxx required a bean of type xxx that could not be found.

    报错: *************************** APPLICATION FAILED TO START ***************************Description:F ...

  5. 解决 error: called object ‘xxx‘ is not a function or function pointer

    代码编译时遇到报错: error: called object 'xxx' is not a function or function pointer| 导致原因:数学表达式错误 或 使用了某些数学函 ...

  6. Unknown column ‘xxx‘ in ‘field list‘

    MySQL数据库插入数据时,出现Unknown column 'XXX' in 'field list' 问题('XXX'表示任意字符).例如下面: -- 删除表 DROP TABLE IF EXIS ...

  7. 插入数据时异常 Unknown column ‘XXX‘ in ‘field list‘

    Unknown column 'XXX' in 'field list' 报错如图: 解决方式 我排除了字段无法对应等一系列问题 最后无可奈何把该字段从表中删除再添加就好了 疑问: 虽然问题是解决了, ...

  8. 解决windows下Error:node with name rabbit already running on “XXX” 和管理页面打不开问题

    背景:重启电脑后,发现rabbit的控制台页面无法打开,启动rabbit,抛如下异常:Error:node with name "rabbit" already running o ...

  9. mysql1526_MySQL数据库插入数据出现 ERROR 1526 (HY000): Table has no partition for value xxx

    MySQL数据库插入数据出现 ERROR 1526 (HY000): Table has no partition for value xxx 工作的时候发现无法插入数据,报错: ERROR 1526 ...

最新文章

  1. POJ-3662 Telephone Lines 二分+双端队列
  2. 【转载】zookeeper学习
  3. Linux系统入门学习:在Debian或Ubuntu上安装完整的内核源码
  4. QT Openssl no OPENSSL_Applink 解决
  5. Neither the JAVA_HOME nor the JRE_HOME environment variable is defined 完美解决(tomcat error)
  6. 判断是否是日期格式_Java8新特性之新世间与日期
  7. 061 实例15-霍兰德人格分析雷达图
  8. 『不再迷茫 - 正则表达式』JS正则要点梳理 持续更新
  9. 第三代oid铺码软件_点读笔的原理
  10. 基于STM32设计的车库监控报警系统
  11. 企业微信页面在电脑端进行调试的方法
  12. 工作那些事(二十八)项目管理模式:项目型、职能型、矩阵型
  13. LaTeX 长度和单位 Lengths Units
  14. 使用C语言绘制变换前与变换后的三角形图形——变换矩阵
  15. java课设心得体会2000字_java课程设计报告心得体会
  16. ME3616-OPENCPU完整调试笔记
  17. 基于视词袋模型的场景识别
  18. jQuery入门 jQuery入门第三天
  19. 史上最全的FTP网址
  20. 三国志战略版:Daniel_新晋减伤战法-奇计良谋

热门文章

  1. python语言pos_关于python:NLTK所有可能的pos标签是什么?
  2. 一个求索者【无标题】
  3. 计算机毕业设计Java南京新东方学校家校通系统(源码+系统+mysql数据库+lw文档)
  4. 反反爬虫 大众点评-图片文字破解 2020年6月6日更新
  5. Qt 仿360悬浮球
  6. Red Hat 镜像下载
  7. 小甲鱼第016讲:序列!序列! | 课后测试题及答案
  8. vue 首页白屏优化
  9. 什么是大数据的ETL
  10. Problem B. 涮羊肉