Mohamed Nabli
Mohamed Nabli

Reputation: 1649

Posted raw data to restController become null

I have found some simillar questions, but couldn't find an answer that works for me.

The problem is when I post data from Postman, in the controller I get null values,

Postman request/response

here is the controller :

@RestController
public class LoginPageController extends AbstractPageContoller{

    @RequestMapping(value="login",method=RequestMethod.POST)
    public LoginForm login(@RequestBody LoginForm loginForm) {
        System.err.println(loginForm.getLogin());
        return loginForm;
    }
}

and here is the class that I try to send as data to the controller :

public class LoginForm{

    private String login;
    private String password;

    //Getters and setters
}

Thanks for your help

Upvotes: 0

Views: 58

Answers (1)

niekname
niekname

Reputation: 2616

Your input data is wrong: it should be:

{ "login" : "aaa", "password" : "aaa" }

Upvotes: 1

Related Questions