I am getting an exception while posting a call to Spring controller
Exception is:
org.springframework.web.bind.MissingServletRequestParameterException : Required Long parameter 'userId' is not present"
My Javascript file is:
$scope.removeUser = function(user){
var userId = JSON.stringify(user);
$http.post('/portal/settings/user/deletecustomeruser', userId).success(function(data){
$scope.response = data;
})
}
}
The Spring controller code is:
@RequestMapping( value = "/user/deletecustomeruser", method = RequestMethod.POST , headers="Accept=application/json")
public @ResponseBody String deleteCustomerUser( @RequestParam (value = "userId") Long userId,
HttpServletRequest request )
throws Exception
{
String returnString = "";
User user = userService.getUserById( userId );
When I put (required = false)
, then the userId
value became null
.
The JavaScript controller is clearly sending the "userId"
in JSON format, but from the controller side there is some issue.
I checked almost all questions in stackoverflow, but the given solutions didn't help.
{"userId":123}
– Plovdiv