jquery - How to save data in a class object ,sent as json object from jsp page to controller in spring using jackson? -
jquery - How to save data in a class object ,sent as json object from jsp page to controller in spring using jackson? -
i trying send json object jsp page using jquery ajax controller in spring framework. want fetch jsonobject elements , store in class object using jackson. here have tried: jsp page:
function callme(){ var jsondataobject = new object(); jsondataobject.name = "abc"; jsondataobject.pwd = "123"; var jsondata = json.stringify(jsondataobject); $.ajax({ type:"get", url:"/test", async: false, data:{jsondata:jsondata}, datatype:"json", success:function(data){ }
controller:
@requestmapping (value = "/test", method = requestmethod.get) @responsebody public string test(@requestbody user obj) { system.out.println("i in user"); responsevo respvo = new responsevo(); system.out.println("user name is:"+obj.getname()); system.out.println("user password is:"+obj.getpwd()); }
what got 415 unsupported media type error. please help.
you have specify type of info used controller :
@requestmapping (value = "/test", method = requestmethod.get,consumes = "application/json) @responsebody public string test(@requestbody user obj) { system.out.println("i in user"); responsevo respvo = new responsevo(); system.out.println("user name is:"+obj.getname()); system.out.println("user password is:"+obj.getpwd()); }
jquery json spring jsp
Comments
Post a Comment