解决 spring mvc 下post json出现HTTP Status 400 The request sent by the client was syntactically incorrect
当你觉得你的配置一切正常,并且无数次检查了请求json参数与javabean都是一致的,但就是报上面的错的时候,那你可能遇到跟我一样的问题。
跟踪Spring执行@RequestBody的过程发现底层的真实错误是:
org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: No content to map due to end-of-input at [Source: org.apache.catalina.connector.CoyoteInputStream@7abd6f93; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input at [Source: org.apache.catalina.connector.CoyoteInputStream@7abd6f93; line: 1, column: 1]
也就是没有内容,说明参数没有传进来。
实事上参数是有的,只不过参数是通过InputStream写入的,而在过滤器或执行@RequestBody之前的任何地方你可能从流中读出了json参数,而ServletStream是不可重复读的,所以当@RequestBody再从InputStream中读参数时就为空了。
知道原因了就好解决,inputStream不能重复读,但你又必须读多次怎么办?
解决办法:
request.getInputStream()只能获取一次的问题
相关推荐
The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. doGet...
(c) typing a syntactically correct SQL query that uses column and table names similar to the correct column and table names in a database (d) writing an English description of the data that the user...
It was developed as an extension of the original Backus Naur Form (BNF) by John Backus and Peter Naur in the 1960s. EBNF provides a more detailed and flexible method for defining the structure of a ...
the SNMP Trap and SNMP Inform packets that were sent from arbitrary SNMP devices or applications on the network. MIB Browser can monitor several SNMP devices simultaneously and contains features like...
The book's unique approach is based on a family of syntactically simple pedagogical languages that allow students to explore programming language concepts systematically. It takes as premise and ...
### CSS: The Missing Manual, 4th Edition - 关键知识点概览 #### 一、基础知识:HTML与CSS的结合 - **HTML5标签**:本书首先介绍了如何编写友好的HTML代码,特别是那些被现代浏览器所识别和支持的HTML5标签。这...
《Pragmatic Guide to Sass 3》是一本由Hampton Lintorn Catlin与Michael Lintorn Catlin共同编写的关于Sass(Syntactically Awesome Style Sheets)的专业指南。本书旨在帮助前端开发者更好地理解和运用Sass这一...
【tog-card-client】是一个项目模板,它为开发React应用程序提供了一个基础框架,使用了现代前端技术栈,包括Typescript、Tailwind CSS、SASS、ESLint和Prettier。这个项目旨在帮助开发者快速启动一个新的React项目...
【标题】:“The-First-Timers”:一个关于幻想足球联赛的项目 在这个名为"The-First-Timers"的项目中,我们看到的是一场充满激情的幻想体育活动,特别是聚焦于足球领域的“第一个计时器”联赛。这个联赛已经进入了...
Employ Syntactically Awesome Stylesheets, CSS3, and Sassy CSS Table of Contents Chapter 1 Introduction to Java EE and HTML5 Enterprise Development Chapter 2 Persistence Chapter 3 RESTful Resources ...
当与React结合使用时,CSS模块可以导入SASS(Syntactically Awesome Style Sheets)文件,这是一种预处理器,扩展了CSS,增加了变量、嵌套规则、混合等功能。SASS文件可以编译成普通的CSS,然后作为模块在JavaScript...
AQuery is a lightweight library that allows UI manipulation in a syntactically similar way to the Javascript library JQuery. AQuery aims to remove the boilerplate code that comes with UI manipulation ...
"SCSS"是Sass(Syntactically Awesome Style Sheets)的预处理器,它扩展了CSS语言,引入了变量、嵌套规则、混合、函数等特性,使得CSS编写更易于维护和扩展。SCSS文件可以被编译成标准的CSS格式,供浏览器解析使用...
标题"Mern-azure-client"揭示了我们正在讨论的是一个基于MERN栈的项目,它已经集成了Azure服务,特别是客户端部分。MERN是MongoDB、Express.js、React和Node.js的首字母缩写,是一种流行的JavaScript全栈开发框架。...
通过Sass(Syntactically Awesome Stylesheets)预处理器,可以调整颜色、字体、间距等变量,轻松创建独特的品牌形象。 5. **JavaScript插件**:除了基本的CSS组件,Bootstrap还包含了一系列基于jQuery的JavaScript...
such cases, so that they may be fixed sooner.Unsafe package is used by the code. While a non-unsafe version of easyjson can be made in the future, using unsafe package simplifies a lot of code by...
8. **预处理器**:如Sass(Syntactically Awesome Style Sheets)和Less,它们扩展了CSS的功能,引入变量、嵌套规则、混合(mixins)等特性,使得CSS代码更加模块化和可维护。 9. **CSS规范与版本**:CSS不断发展,...
然后,课程的重点转向Sass(Syntactically Awesome Style Sheets),这是一个强大的CSS预处理器,它可以引入变量、嵌套规则、混合、函数等高级特性,使得CSS代码更加简洁、可维护。学习者将了解如何安装和设置Sass...