Field error in object ‘xxx‘ on field ‘xxx‘: rejected value [xxx]
文章首发于个人博客,欢迎访问关注: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]相关推荐
- Field error in object ** on field **
错误信息: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindi ...
- 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 ...
- 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 ...
- 使用Feign服务远程调用项目启动时报错:Field xxx in xxx required a bean of type xxx that could not be found.
报错: *************************** APPLICATION FAILED TO START ***************************Description:F ...
- 解决 error: called object ‘xxx‘ is not a function or function pointer
代码编译时遇到报错: error: called object 'xxx' is not a function or function pointer| 导致原因:数学表达式错误 或 使用了某些数学函 ...
- Unknown column ‘xxx‘ in ‘field list‘
MySQL数据库插入数据时,出现Unknown column 'XXX' in 'field list' 问题('XXX'表示任意字符).例如下面: -- 删除表 DROP TABLE IF EXIS ...
- 插入数据时异常 Unknown column ‘XXX‘ in ‘field list‘
Unknown column 'XXX' in 'field list' 报错如图: 解决方式 我排除了字段无法对应等一系列问题 最后无可奈何把该字段从表中删除再添加就好了 疑问: 虽然问题是解决了, ...
- 解决windows下Error:node with name rabbit already running on “XXX” 和管理页面打不开问题
背景:重启电脑后,发现rabbit的控制台页面无法打开,启动rabbit,抛如下异常:Error:node with name "rabbit" already running o ...
- 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 ...
最新文章
- POJ-3662 Telephone Lines 二分+双端队列
- 【转载】zookeeper学习
- Linux系统入门学习:在Debian或Ubuntu上安装完整的内核源码
- QT Openssl no OPENSSL_Applink 解决
- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined 完美解决(tomcat error)
- 判断是否是日期格式_Java8新特性之新世间与日期
- 061 实例15-霍兰德人格分析雷达图
- 『不再迷茫 - 正则表达式』JS正则要点梳理 持续更新
- 第三代oid铺码软件_点读笔的原理
- 基于STM32设计的车库监控报警系统
- 企业微信页面在电脑端进行调试的方法
- 工作那些事(二十八)项目管理模式:项目型、职能型、矩阵型
- LaTeX 长度和单位 Lengths Units
- 使用C语言绘制变换前与变换后的三角形图形——变换矩阵
- java课设心得体会2000字_java课程设计报告心得体会
- ME3616-OPENCPU完整调试笔记
- 基于视词袋模型的场景识别
- jQuery入门 jQuery入门第三天
- 史上最全的FTP网址
- 三国志战略版:Daniel_新晋减伤战法-奇计良谋