サーバー側への呼び出しの投稿中に問題に直面する
例外スタック トレース:
"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 呼び出し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();
},
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);
}