原因分析

根据异常提示:不匹配输入异常,指输入的参数错误,说是只支持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. wkhtmltopdf 代替 itext 将 url 转成 pdf

    通过 itextpdf 的 HtmlConverter.convertToPdf(); 方法生成的pdf 有点让人失望,CSS啥的不起作用了,(有可能我用得不对) 后来用 wkhtmltopdf.ex ...

  2. Pymsql简介

    ###### 什么是PyMysql Pymsql是在Python3.x版本中用于连接Mysql服务器的一个库,Python2中则适用mysqldb ###### Pymsql安装 ```python ...

  3. 【快速阅读二】从OpenCv的代码中扣取泊松融合算子(Poisson Image Editing)并稍作优化

    泊松融合我自己写的第一版程序大概是2016年在某个小房间里折腾出来的,当时是用的迭代的方式,记得似乎效果不怎么样,没有达到论文的效果.前段时间又有网友问我有没有这方面的程序,我说Opencv已经有了, ...

  4. GitLab--简单使用

    1 创建项目组 项目组说明 Private 私有 只有所有者 组内成员或已分配的用户有查看权限(同GitHub收费版的私有仓库) Internal 内部 拥有GitLab账号的成员可以查看 无账号用户 ...

  5. 【计算机网络】soap和rest简单比较整理

    https://www.bilibili.com/video/BV1ht411U7fC/?spm_id_from=333.337.search-card.all.click&vd_source ...

  6. three.js 视频融合

    MixVideo.js代码: //视频融合 import * as THREE from '../build/three.module.js'; import { API } from '../js. ...

  7. 遇到 Request header is too large,你是如何解决的?

    看到群里有小伙伴问,这个异常要怎么解决: java.lang.IllegalArgumentException: Request header is too large 异常原因 根据Exceptio ...

  8. POJ:Dungeon Master(BFS模板题)

    原题链接 思路: 正常的思路,只不过是将二维BFS换成三维的,也算是个模板题吧(PS:DFS超容易超时) #include<iostream> #include<queue> ...

  9. Educational Codeforces Round 109 (Rated for Div. 2) 个人补题记录(A~D,AB思维,C模拟构造,D题DP)

    补题链接:Here 1525A. Potion-making (思维 [题意描述] 作为一个魔法师,现在我想配置一杯药物浓度为 \(k\%\) 的药水, 每次操作能进行添加: 一升水 一升药物精华 作 ...

  10. L3-020 至多删三个字符 (30分) (DP)

    问题描述: 给定一个全部由小写英文字母组成的字符串,允许你至多删掉其中 3 个字符,结果可能有多少种不同的字符串? 输入格式: 输入在一行中给出全部由小写英文字母组成的.长度在区间 [4, 1e6] ...