How do I send string as Springs’ @RequestParam using AngularJS?
In my backend (Spring controller) I have a method with @RequestParam String sentence
as request param. I’d like to my a request (post) to this method by sending appropriate parameters.
In AngularJS I wrote:
$http.post('http://localhost:8080/wordCount', '?sentence=blah')
but backends return the error Required String parameter 'sentence' is not present"
Here’s my controller:
@RequestMapping(value = "wordCount", method = RequestMethod.POST)
public String count(@RequestParam(value = "sentence") String sentence) {
//omitted
}
Source: AngularJS