原因分析

根据异常提示:不匹配输入异常,指输入的参数错误,说是只支持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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. [待解决]报错:JSON parse error: Unexpected character

    {"code":"9999","message":"JSON parse error: Unexpected character ...

  5. 记一次接口调试错误: {"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,结合日志中的报文 ...

  6. 页面白屏并且报错PHP Parse error: syntax error, unexpected end of file in 试了很久总算解决了

    页面白屏并且报错PHP Parse error:  syntax error, unexpected end of file in 试了很久 啥短标记,打开,都试了 最简单的办法 是重新建立一个文件, ...

  7. jackson json转实体对象 com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException

    Jackson反序列化错误:com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field的解 ...

  8. Docker报错“Dockerfile parse error line 1: FROM requires either one or three arguments”

    看官方文档Format: 以 '#' 开头一行被视为评论,出现在其他位置视为参数. 也就不难理解报错原因:将写在同一行的注释视为参数了. 原Dockerfile: 改为:

  9. TP5报错variable type error: array

      variable type error: array 当你在tp5框架中写方法时返回一个数组时,tp5会报错:variable type error: array 这是因为tp5不支持返回数组. ...

  10. jackson json转实体 com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException

    jackson 2.2.2 由于vo中缺少json的某个字段属性引起 2种解决方法 1:vo中添加注解@JsonIgnoreProperties(ignoreUnknown = true) 2.  m ...

随机推荐

  1. SQL SERVER 查询所有表 统计每张表的大小

    (MySQL查看数据库表容量大小)[https://www.cnblogs.com/vipsoft/p/12145059.html] 查询某数据库中的所有数据表 SELECT name as tabl ...

  2. pytest参数化及应用

    Pytest 安装pytest #安装pytest pip install pytest #检查是否安装 pytest --version 创建第一个测试 def func(x): return x ...

  3. docker安装aira2 pro与ariang以及alist推送下载的配置

    Docker一键安装 aira2-pro: docker run -d --name aria2 --restart unless-stopped --log-opt max-size=1m -e P ...

  4. 用 ChatGPT 写一篇《ChatGPT 会取代我们的工作吗》

    自从 ChatGPT 火爆以后,最常谈到的话题就是 ChatGPT 会取代我们的工作吗?在写这篇内容时我有个大胆的想法,那就是让 ChatGPT 来取代我的工作. 首先,我决定直接让 ChatGPT ...

  5. 【辅助工具】SVN使用

    1.在对应路径下右键SVN checkout 2.输入对应的网址.用户名.密码 3.提交右键选择SVN commit.覆盖选择SVN update 4.编辑的时候右键TortoiseSVN-get l ...

  6. 2018年第九届 蓝桥杯C组 C/C++决赛题解

    蓝桥杯历年国赛真题汇总:Here 1.年龄问题 s夫人一向很神秘.这会儿有人问起她的年龄,她想了想说: "20年前,我丈夫的年龄刚好是我的2倍,而现在他的年龄刚好是我的1.5倍". ...

  7. Java中数组、集合、链表、队列的数据结构和优缺点和他们之间的区别

    数组:.长度固定.可以存储基本类型,也可以存储引用类型.存储元素类型一致数组可以在内存中连续存储多个元素的构造,在内存中的分配也是连续的数组中的元素通过数组的下标进行访问的,下标从0开始的优点 :按照 ...

  8. IDEA插件Material Theme UI 激活

    介绍 "Material Theme UI" 是一款为 IntelliJ IDEA 提供现代化材料设计主题的插件,通过重新设计IDE的外观,为开发人员带来更加美观.富有活力的用户体 ...

  9. nginx 工作原理及特点

    本文为博主原创,未经允许不得转载: nginx 简介:是一个高性能 HTTP 和 反向代理 服务器. Nginx 特点是占有内存少,并发能力强,事实上 Nginx 的并发能力确实在同类型的网页服务器中 ...

  10. SpringBoot - 阿里云OSS - 上传和删除

    1,首先在 pom.xml 中加入maven依赖 <!-- 阿里云oss --> <dependency> <groupId>com.aliyun.oss</ ...