背景
今天在调试项目的时候遇到一个坑,用Postman发送一个post请求,在Springboot项目使用@RequestBody接收时参数老是报不存在,可是屡次检查postman上的请求格式以及项目代码都没有问题java
Postman:
请求参数:spring
{ "firstName":"fdsaf", "lastName":"dfasdf" }
Controller:
json
Entity
经过debug模式能够发现传进到实体的参数都为nullspringboot
解决思路
通过分析,有多是springboot解析器在解析json过程当中出现问题,因字段名驼峰命名没法匹配字段名致使,加上以下注解便可:post
//@JsonProperty(value = "firstName")
修改后结果:spa