Java tests POST request with postman. The incoming parameter is empty.





get
PUTid...

clipboard.png

Mar.04,2021

the parameters of your post are not in json format, but postman all give you an error.


try the following one

clipboard.png


if you accept the three id,name,age fields in the object, your parameters should be the following, right? Key is the parameter name, according to the way you wrote it above, the parameter name is user, isn't it?

{
    "name":"aa",
    "id":1,
    "age":55
}


No postman, installed

var data="{\"id\":\"1\",\"age\":22,\"name\":\"aa\"}";
    $.ajax({
        type:'post',
        url:url,
        data:data,
        contentType:"application/json;charset=utf-8",
        success:function(msg){
            
        }
    }); 
(@RequestBody User user)

put aside the meaning of this annotation of @ modelattribute.
the parameters of the get request can be placed in the header and can be received. If it is a post request and the parameter is in the format of json and placed in body, it is recommended to accept it with @ requstBody in the method.
the difference between these two items is mainly based on how your front end passes the value and how the back end receives it. Generally divided into restful style, and header and front-end transmission of json-based form, so that the background can receive the front-end information to do processing.


in the backend code, the format (., User parameter name of the request parameter) so this is a formdata request, so the parameter should be passed in form-data format instead of raw (JSON) in Postman. Different from the request parameter (@ RequestBody User parameter name)

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36c08-2b88f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36c08-2b88f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?