org.springframework.web.bind.MissingServletRequestParameterException

Facing issue while posting call to server side

Exception stack trace :

"org.springframework.web.bind.MissingServletRequestParameterException: Required int parameter 'answerId' is not present\r\n\tat org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.raiseMissingParameterException(AnnotationMethodHandlerAdapter.java:773)\r\n\tat org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestParam(HandlerMethodInvoker.java:509)

Javascript call in controller.js

$scope.saveCorrectAnswer = function(answerId) {

        var answerIdVal = 0;
        answerIdVal = answerId;
        if(document.getElementById(answerId).className == 'ico-white-check') {
            $scope.answer.correct = 'Y';
        } else{
            $scope.answer.correct = 'N';
        }

        Answer.update({answerId: answerIdVal, correct: $scope.answer.correct}, function(response) {
            // On success go to Exchange
            //$route.reload();
        },

Mapping in service controller in java:

@RequestMapping(method = RequestMethod.PUT, consumes = "application/json", produces = "application/json")
@ResponseBody
public void addCorrectAnswer(@RequestParam int answerId, @RequestParam String correct) {

    getAnswerDAC().addCorrectAnswer(answerId, correct);

}

@RequestParam has an attribute required which is true by default. If answerId is not required, change the annotation and parameter type as follows...

@RequestMapping(method = RequestMethod.PUT, consumes = "application/json", produces = "application/json")
@ResponseBody
public void addCorrectAnswer(@RequestParam(required = false) Integer answerId, @RequestParam String correct) {
     getAnswerDAC().addCorrectAnswer(answerId, correct);
}

Edit: Since answerId is a primitive value in your example, you would also need to provide a defaultValue in the annotation. Providing a defaultValue implicitly sets required to false, so I'll leave it out of the example...

@RequestMapping(method = RequestMethod.PUT, consumes = "application/json", produces = "application/json")
@ResponseBody
public void addCorrectAnswer(@RequestParam(defaultValue = 0) int answerId, @RequestParam String correct) {
     getAnswerDAC().addCorrectAnswer(answerId, correct);
}

Hope this helps