My sample code.
js
function sendMessage(message) {
$.ajax({
url : "/sample/push/" + message,
processData : false,
contentType : "text/html; charset=utf-8",
type : 'POST',
success : function(response) {
// get response
},
error : function(request, status, error) {
},
});
}`
controller
@RequestMapping(value = "/push/{message}")
public @ResponseBody String processResult(@PathVariable String message) {
// "your json String"
return pushService.pushMessage(message);
}
ajax call and spring MVC tutorial - link : this tutorial XD