原因分析

根据异常提示:不匹配输入异常,指输入的参数错误,说是只支持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. -source 1.5 中不支持静态接口方法调用

    -source 1.5 中不支持静态接口方法调用 (请使用 -source 8 或更高版本以启用静态接口方法调用) File -> Project Structure File -> Se ...

  2. WSL2 配置 ArchLinux 初始化环境

    这篇文章针对的是在 Win11 系统的 WSL2 下安装 ArchLinux 系统, 网上很多中文教程都是使用 LxRunOffline 去做的,但是实际上该方法已经过时了,目前有更加先进的ArchW ...

  3. <vue 路由 4、嵌套路由>

    一.效果 点击about后,新闻和体育属于about的子路由调用的页面 知识点说明 路由里使用children属性可以实现路由的嵌套 三.代码结构 注:主要是标红的几个文件 四.代码 重新编写这几个文 ...

  4. 十六、企业级私有仓库harbor

    系列导航 一.docker入门(概念) 二.docker的安装和镜像管理 三.docker容器的常用命令 四.容器的网络访问 五.容器端口转发 六.docker数据卷 七.手动制作docker镜像 八 ...

  5. 3 Englishi 词根

    1 -able 能..的:具有...性质的 useable moveable adaptable 2 -al  具有...性质的; 属于...的 personal natural regional - ...

  6. python代码打包exe程序

    1.安装pyinstaller 命令行输入:pip install pyinstaller 2.打包exe程序 输入命令:pyinstaller -F -w *.py(星号是.py的全部路径) pyi ...

  7. loadrunner12的安装教程

    一.LR12安装包: 链接:https://pan.baidu.com/s/1UU304e-nP7qAL-fV8T39YQ 密码:jpln 二.LR12安装: 1.下载完成后点击解压

  8. configmap 和 secret 概述

    本篇文章是对 configmap 和 secret 的一个总结,详细信息可看 这里 1. configmap 和 secret 概述 在 container 的 image 中可通过 ENTRYPOI ...

  9. @RequestParam与@RequestBody使用对比

    转载请注明出处: @RequestParam 用来处理Content-Type: 为 application/x-www-form-urlencoded编码的内容. (Http协议中,如果不指定Con ...

  10. 带你熟悉NLP预训练模型:BERT

    本文分享自华为云社区<[昇思技术公开课笔记-大模型]Bert理论知识>,作者: JeffDing. NLP中的预训练模型 语言模型演变经历的几个阶段 word2vec/Glove将离散的文 ...