RequestBody is a json formatted parameter converted to Java Type,
for receiving content-type application/json requests, data Type is json: {” aaa “:” 111 “, “BBB” : “222”}
When not using the @RequestBody annotation, one may receive data submitted in a Content-type application/ X-www-Form-urlencoded Type request, in a format of AAA =111& BBB =222,form form submission and jQuery’s.post() method send requests of this type.
JQuery’s $. Ajax (url, [Settings])
1. The default ContentType value is: Application/x-www-Form-urlencoded; Charset = utf-8
this format is the form submission format, the data is key1=value1& Key2 = value2 format
2. Although the ajax data attribute value format is :{key1:value1,key2:value2}, it will be changed to key1=value1& The key2=value2 format is submitted to the background
3. If Ajax wants to interact with SpringMVC, key1=value1& Key2 =value2 format, springMVC in the background only need to define the object or parameter, will be automatically mapped.
4. If springMVC parameters have @RequestBody annotation (receive JSON string format data), Ajax must convert the date property value to JSON string, not to JSON object (js object, automatically converted to key=value). Also, change the value of the contentType to: Application/JSON; Charset =UTF-8, so attributes annotated with @RequestBody are self-mapped to values
note that the requested parameters are not in json format, not in json format, and do not annotate with @requestbody
Read More:
- Required request body is missing with ContentCachingRequestWrapper
- TypeError: Failed to execute ‘fetch‘ on ‘Window‘: Request with GET/HEAD method cannot have body.
- TypeError: putText() missing required argument ‘text‘ (pos 2)
- configure: error: libpam required but missing
- Macro generated_ UCLASS_ Body () and generated_ Analysis of body ()
- IIS “Bad Request – Request Too Long. HTTP Error 400. The size of the request headers is too long.”
- Error type referred to is not an annotation type:RedisCache
- XML tag has empty body less… (Ctrl+F1) Reports empty tag body. The validation works in XML / JSP
- Bad Request – Request Too Long. HTTP Error 400. The size of the request headers is too long
- The problem that headers [‘content-type ‘] does not work is set in the Axios get method request interface
- In the HTML page request Ajax times 400 error, solve Yii submit post form 400 error, and Ajax post request 400 problem (example code)
- Solve the problem of jdk8 after win7 is installed. Has value ‘1.8’, but ‘1.7’ is required
- Solve the problem that stdole32.tlb is missing when win7 Microsoft Office 2007 Pro Plus excel is opened
- Flask Request an extension before_request after_request errorhandler
- HTTP 400 error – bad request
- After Vue is packaged, a blank page appears, an error is reported in the resource request, and there is no error handling scheme
- JS Ajax request is successful, the response displays “failed to load response data”
- The @ Autowired annotation in springboot is invalid in ordinary classes. How to solve and use the null pointer exception java.lang.nullpointerexception
- Allegro’s solution to “symbol is missing a refdes”
- Notes on @ pathvariable annotation in springcloud openfeign