I'm trying to send a string from my view to my controller, but I keep getting the error that "text" is not present.
this is my javascript
$scope.sendMsg = function(){
console.log($scope.my.message);
data = {"text" : $scope.my.message};
$http({
method:'POST',
data:data,
contentType: "application/json; charset=utf-8",
dataType:"json",
url:'/post-stuff'
}).then(function(response){
console.log(response);
});
}
My rest controller :
@RequestMapping(value= "/post-stuff", method=RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<PostTextResult> postStuff(@RequestParam(value= "text") String text){
System.out.println(text);
return new ResponseEntity<PostTextResult>(stuff.postTextContent(text), HttpStatus.OK);
}