Error resolution: Resolved [org.springframework.web.bind.MissingServletRequestParameterException

问题:Resolved[org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter ‘userRealName’ for method parameter type String is not present]

When the front-end and back-end are jointly debugged, when the front-end calls the back-end interface, the request reports an error Required String parameter 'xxx' is not present, and the status code is 400.

insert image description here
Backend controller interface:
insert image description hereinsert image description here

reason:

It is a problem caused by the interface receiving parameters.
The @RequestParam annotation is often used to receive data, and this annotation only supports the parsing of form-type data, and does not support the json data format.
Then the data transmitted from the current end is in json format, it will fail to parse, and the request interface will report the above error.
Solution:
1. The easiest solution is to change the @RequestParam annotation to @RequestBody annotation, because it supports the parsing of json data format.
2. It can also be solved by using param to pass parameters through Postman. Here I use the second method

insert image description here

Guess you like

Origin blog.csdn.net/qq_45821255/article/details/126998944