The background can only receive get requests, and the data received by post is null,. What is wrong with this?

problem description

the backend can only receive get requests, and the data received by post is null

.

the environmental background of the problems and what methods you have tried

take a look at the break point. The value passed by the post request is null
tested with postman. I thought it was a problem with the testing software. Then I wrote a form form test, and the result is the same.
cannot receive data using post.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

@RequestMapping(value = "login.do", method = RequestMethod.GET)
@ResponseBody
public ServerResponse<User> login(String username,String password, HttpSession session){
    ServerResponse<User> response = iUserService.login(username,password);
    if(response.isSuccess()){
        session.setAttribute(Const.CURRENT_USER,response.getData());
    }

    return response;
}

what result do you expect? What is the error message actually seen?

username and password should be able to receive the value passed by the front end
, but actually not. The value is null

.
Mar.28,2021

@ RequestMapping (value = "login.do", method = RequestMethod.GET) what you write here is a get request


this is actually a front-end problem.
guess that the data sent by your front end is in json format.
data in json format, which cannot be received in the background. You can receive it with @ ResquestBody (not @ ResponseBody), but you can't receive multiple fields normally. If you want to receive it, you should define your own class or something.

the correct thing to do is to change the request data format of the foreground.

let params = new FormData();
params.append('username', 'test');
params.append('password', 'test');
let config = {
    headers: {'content-type': 'application/x-www-form-urlencoded'}
};  //

axios.post('login.do', params, config).then((response) => {
    console.log(response.data);
})

request headers


request headers


request headers allow the front end to change content-type to json, or the back end to use jackson to deal with. Do not use the RequestMappingHandler, that comes with Spring to throw the pan time to each other


although it is not clear why, the tomcat problem is solved by resetting it.

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-1e482eb-44c92.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-1e482eb-44c92.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?