项目整合登录验证功能时遇到如下错误:
org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing
错误原因:
误把@GetMapping与@RequestBody放在一起使用
@GetMapping("login")
public R loginUser(@RequestBody UcenterMember member){
}
解决方式:
@GetMapping换成@PostMapping
@PostMapping("login")
public R loginUser(@RequestBody UcenterMember member){
}
stackoverflow上的一个类似问题:
另附GET与POST的区别:
https://blog.fundebug.com/2019/02/22/compare-http-method-get-and-post/
- Post link: http://example.com/2021/06/01/Spring%E6%B3%A8%E8%A7%A3GetMapping%E4%B8%8ERequestBody%E4%B8%8D%E8%83%BD%E6%90%AD%E9%85%8D%E4%BD%BF%E7%94%A8/
- Copyright Notice: All articles in this blog are licensed under unless otherwise stated.