I am trying to capture data from one HTML form and send it to MVC controller but the below code doesn't work. Can someone please help me here.
var form = JSON.stringify(jQuery('#project_form').serializeArray());
$.ajax({
contentType : "application/json; charset=utf-8",
dataType : "json",
type: "POST",
url: "/SE/doLogin",
data: form,
success: function(response){
window.location.href = response;
And here is my controller
@RequestMapping(value = "/doLogin",method = RequestMethod.POST,consumes = "application/json",produces="text/plain")
@ResponseBody
public String sayHello(@RequestBody TestDao templateModel ){
System.out.println("say");
System.out.println(templateModel.getEmail());
TestMethod t1 = new TestMethod();
t1.getValues();
return "newsFeed";
}
When I am not keeping any argument , it works and S.o.p is getting printed on console. I am not sure while @RequestBody is not working.