org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing:
时间: 2023-10-18 18:31:11 浏览: 49
org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing是一个Spring框架中的异常。该异常表示请求的请求体缺失,即在处理请求时,需要读取请求体的内容,但请求体却为空。
有多种可能导致这个异常的发生,比如前端发送的请求没有携带请求体,或者请求体的内容格式不正确。
根据引用和引用***中。这个方法使用了@RequestBody注解,表示需要从请求体中读取参数,但实际请求中没有提供请求体,导致异常被抛出。
根据引用的代码片段,可以看到在该方法上使用了@PostMapping注解,并且定义了路径为"/send4Order/{telephone}"。这意味着该方法需要接收一个路径参数telephone,并且从请求体中读取其他参数。如果没有提供请求体,就会抛出HttpMessageNotReadableException异常。
要解决这个异常,可以检查发送请求的前端代码,确保请求体正确地被发送到后端。另外,也可以考虑将@RequestBody注解换成@RequestParam注解,将参数直接从URL中获取,而不依赖请求体。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [org.springframework.http.converter.HttpMessageNotReadableException错误原因及解决办法](https://blog.csdn.net/qq_43055855/article/details/110095103)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing](https://blog.csdn.net/z1427094386/article/details/120386072)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]