java - Why am I getting 400 bad request with AngularJs post? -


I use Spring MVC and AngularJs to create a web application. I send a request to the server, but I'm getting a 400 error bad request . I configure message converter for Jason format in the spring servlet configuration file. I wonder why I got this error.

Here's my angular service:

  save: function (user) {return $ http ({method: 'POST', Url: '/ app-web / user / Create ', contentType: "application / json", data: user}); }   

And on the server side, I have a spring MVC controller as described below:

  @RequestMapping (value = "/ user / create" Method = RequestMethod.POST) @ResponseBody Make Public StringCount (@RequestBody User User) {// Return some argument "OK"; }   

I saw a bit more: When I remove @equestBody in the controller, I do not have 400 error but user null @RequestMapping (value = "/ user / create", method = RequestMethod.POST) @ResponseBody makes public string rights (user users) {// Some logic returns "OK" ; }

The problem was about the user form. I had the last name, first name, email, password, password 1 but the user is not password 1 attribute in the Java object when the JSN data provided by the request does not conform to the Java object, then the data from the JSON Kanan Java object Can not match.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -