@RequestBody中使用@DateTimeFormat报错:JSON parse error: Expected array or string.; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException
原因分析
根据异常提示:不匹配输入异常,指输入的参数错误,说是只支持String类型和Array数组类型的。
@PostMapping("/test")
public Dto getWindStorageOutputPower(@ApiIgnore @RequestBody @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate localDate) {
System.out.println(localDate);
return null;
}
修改:
将输入参数改为String类型的日期。比如 2021-06-04;或者将@RequestBody改为@RequestParam。
其他场景
- 如果接受前端的是实体类,日期为实体中的一个属性,需要将@DateTimeFormat加到成员变量上,而不是在方法参数中
@RequestBody中使用@DateTimeFormat报错:JSON parse error: Expected array or string.; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException的更多相关文章
- JSON parse error: Cannot deserialize instance of `int` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc
代码程序: @PostMapping("selectById") @ResponseBody public Result selectById(@RequestBody int i ...
- JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of j
异常信息如下: JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token ...
- HttpMessageNotWritableException: Could not write JSON: Infinite recursion (StackOverflowError); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Infinite
org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Infinite r ...
- [待解决]报错:JSON parse error: Unexpected character
{"code":"9999","message":"JSON parse error: Unexpected character ...
- 记一次接口调试错误: {"timestamp":"2019-09-11T03:04:30.036+0000","status":500,"error":"Internal Server Error","message":"Could not write JSON: Object is null; nested exception is com.fasterxml.jackson
接口测试中用postman测试返回是正常的,但是使用其他人去调用就出错了,找了半天,才想起来使用了nginx,用于端口的代理转发.然后根据错误信息发现json格式的某个字段为null,结合日志中的报文 ...
- 页面白屏并且报错PHP Parse error: syntax error, unexpected end of file in 试了很久总算解决了
页面白屏并且报错PHP Parse error: syntax error, unexpected end of file in 试了很久 啥短标记,打开,都试了 最简单的办法 是重新建立一个文件, ...
- jackson json转实体对象 com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException
Jackson反序列化错误:com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field的解 ...
- Docker报错“Dockerfile parse error line 1: FROM requires either one or three arguments”
看官方文档Format: 以 '#' 开头一行被视为评论,出现在其他位置视为参数. 也就不难理解报错原因:将写在同一行的注释视为参数了. 原Dockerfile: 改为:
- TP5报错variable type error: array
variable type error: array 当你在tp5框架中写方法时返回一个数组时,tp5会报错:variable type error: array 这是因为tp5不支持返回数组. ...
- jackson json转实体 com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException
jackson 2.2.2 由于vo中缺少json的某个字段属性引起 2种解决方法 1:vo中添加注解@JsonIgnoreProperties(ignoreUnknown = true) 2. m ...
随机推荐
- C# 内存缓存工具类 MemoryCacheUtil
C# 内存缓存工具类 MemoryCacheUtil using System; using System.Collections.Concurrent; using System.Collectio ...
- AtCoder Beginner Contest 174 个人题解(ABC水题,D思维,E题经典二分,F离线树状数组)
做完本期以后,最近就不会再发布 AtCoder 的往届比赛了(备战蓝桥杯ing) 补题链接:Here ABC题都是水题,这里直接跳过 D - Alter Altar 题意:一个R-W串,可以进行两种操 ...
- springboot启动类源码探索一波
举个例子: 这是一个原始的Spring IOC容器启动方法,我们需要AnnotationConfigApplicationContext这个类有如下几个步骤 1. 创建构造方法,根据我们所传入的Ap ...
- 供应链安全情报 | cURL最新远程堆溢出漏洞复现与修复建议
漏洞概述 cURL 是一个支持多种网络协议的开源项目,被广泛集成到自动化构建.网络测试.网络数据采集以及其他网络相关的任务中,备受开发者和系统管理员青睐. cURL在2023年10月11日下午紧急发布 ...
- webpack配置自动打包相关的参数
- 浅谈 Docker 网络:单节点单容器
1.Docker 网络模型 Docker 在 1.7 版本中将容器网络部分代码抽离出来作为 Docker 的网络库,叫 libnetwork.libnetwork 中使用 CNM(Container ...
- ClickHouse中“大列”造成的JOIN的内存超限问题
ClickHouse中"大列"造成的JOIN的内存超限问题 "大列"是指单行数据量非常大的列,通常是100KiB以上.这样的列会导致JOIN(通常LEFT JO ...
- Multi-Master APB Interconnect
APB总线并不是只有一个master(AHB2APB Bridge),可以通过设计支持多个APB Master,只是比较复杂 Lattice 实现了一款Multi-Master Interconnec ...
- Laravel - 虚拟主机引入静态资源
一. 注意: 引用的静态文件要放在根目录,不要放在assets目录下 二. 引入方法 1. 模板中引入 css <link rel="stylesheet" hr ...
- linux环境C语言实现:h265与pcm封装成AVI格式
前言 不知道是处于版权收费问题还是什么原因,H265现在也并没有非常广泛的被普及.将h265数据合成AVI的资料现在在网上也基本上没有.使用格式化工厂工具将h265数据封装成AVI格式,发现它在封 ...