I am developing a web application with AngularJS and WildFly using Spring also.
My problem is that I am going nuts because the annotation @requestBody appears to work wrong.
This is my service:
@ResponseBody
@RequestMapping(value = "/keyuser", method = RequestMethod.POST,
consumes = "application/json")
public KeyProfileUserSummary updateEmployee(@RequestBody KeyProfileUserSummary keyUser) {
return null;
}
And this is are the members of my object KeyProfileUserSummary:
private Integer id;
private String login;
private String password;
private String firstname;
private String lastname;
private UserRole userRole;
I don't know what is going on but I have tested this service with other types of objects and it works perfectly, but when defining KeyProfileUserSummary it is not working, I get ERROR 400 BAD REQUEST. I have tested to set the @RequestBody to "Object" so at least I can see what is coming, and from my front end, I am getting the following:
{id=3, login=aa, password=a, firstname=Martin, lastname=Müller, userRole=ROLE_USER}
UserRole is an Enum. Important to clearify that KeyProfileUserSummary is just a summary version of KeyProfileUser, but due to all the linked elements I get on the response, I decided to send this lighter class. Testing with KeyProfileUser worked perfectly, I get the JSON object on the Angular side and can send it back.
On the Angular side, I am not doing anything with the object. Just receive it on a list, and when pressing an edit button just send the element on the list back. This is the way I am sending it:
res = $http.post("url.../keyuser", user);
The thing is that I had everything working perfectly with KeyProfileUser, but as the database can get really huge and the reference are quite a lot, I decided to switch to this lighter class, but now I only get this ERROR 400 BAD REQUEST... And I am about to hang myself :P
Thanks for your help!