Unable to convert Javascript object to Java Model

My Spring controller and client side Javascript code are as follows and for some reason the Javascript object is unable to reach the Spring controller in the Object form. My Controller code is as follows:

@RequestMapping(value = "/addRating", method = RequestMethod.POST, headers = "Accept=application/json")
public EmployeeRating addRating(@ModelAttribute("employeeRating") EmployeeRating employeeRating) {  

    return employeeRating;

My Javascript code below:

          url: 'https://myrestURL/addRating',
          type: 'POST',
          dataType: 'json',
          data: {
              'name': 'Name',
              'rating': '1'
          contentType: 'application/json; charset=utf-8',
          success: function (result) {
             // CallBack(result);
             window.alert("Result: " + result);
          error: function (error) {
              window.alert("Error: " + error);

The EmployeeRating object in Java has id, name and rating fields so there’s no mismatch.

Source: stackoverflow-javascript

Sending form from Angular JS to Spring

I have simple application AngularJS and Spring boot. I want to pass whole form pre-filled by user to my app and register . Usually I had no problems – was passing JSON obj with correct structure and presto. However here I just run in cricle.
The form payload is sent to controller, address mapping is correct , but java form content is empty

Payload sent to server:


Here is my html:

There was a problem registering. Please try again.
<form role="form" name="userForm" ng-submit="register()">
<button type="submit" class="btn btn-primary">Submit</button>

Here java script

app.controller('register', function ($scope, $rootScope, $http) {
    $scope.formData = {};
    $scope.register = function () {
        $http.post('/api/register', {userform: $scope.formData}).then(
            function (resposne) {
            function (response) {
                console.log("Register error")

And here controller:

public class ApiController {

    @RequestMapping(value = "/register", method = RequestMethod.POST)
    public String register(@RequestBody RegisterForm userform) {
        System.out.println("name:" + userform.getName());
        System.out.println("surname:" + userform.getSurname());
        return "OK";

and last but not least RegisterForm:

public class RegisterForm {
    private static final String NOT_BLANK_MESSAGE = "Cannot be blank";
    @Email(message = "Not email")
    private String email;

    @NotBlank(message = RegisterForm.NOT_BLANK_MESSAGE)
    private String name;

    @NotBlank(message = RegisterForm.NOT_BLANK_MESSAGE)
    private String surname;

    @NotBlank(message = RegisterForm.NOT_BLANK_MESSAGE)
    private String password;

    @NotBlank(message = RegisterForm.NOT_BLANK_MESSAGE)
    private String confirmpassword;


Source: stackoverflow-javascript

JSP doesn’t show cookie for the first time

I set a cookie in javascript, not in controller and I want to check if that cookie exists in JSP. My cookie is set, but I have to reload the page manually in order to see it in jsp. I did reload method in javascript, but I still have to reload page once more.

getting cookie: ${cookie['_sYrV'] } or ${cookie._sYrV }


set_cookie("name","value", 1);
window.onload = function () {
    if (!localStorage.reloadOnce) {
        localStorage.setItem("reloadOnce", "true");

var set_cookie = function(name, value, day) {
    var d = new Date();
    d.setTime(d.getTime() + (day * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toUTCString();
    document.cookie = name + "=" + value + ";" + expires + ";path=/";

What should I do in order to see the cookie in jsp without reloading the page manually?

Source: stackoverflow-javascript