I'm using ajax call to submit a form. But I'm not able to access the parameter as a modelattribute.
Ext.Ajax.request({
url: 'url',
headers: { 'Content-Type': 'application/json' },
params : Ext.JSON.encode(form.getValues()), //this is the parameter in jason pattern
success: function(response, options) {
var result = Ext.JSON.decode(response.responseText, true);
if (result.success) {
Ext.Msg.show({
title:'DataBase',
msg: result.message,
buttons: Ext.Msg.OK,
icon: Ext.Msg.INFO
});
My doubt is that can i access this parameter as a modelattribute as in the given code below. ?
@RequestMapping(value="/employee/new", method = RequestMethod.POST )
@ResponseBody public String doAddEmp(@RequestBody String Str){
try{
empServ.setError();
if(empServ.addEmp(Str)){
return "{success:true, message:'Insertion Successfull'}";
}else
return "{success:false, message:\""+empServ.returnError()+"\"}";
}
catch(Exception e){
e.printStackTrace();
return "{success:false, message:'SQL ERROR'}";
}
}
I would be very thankful to hear a good suggestion for my doubt. If this is a wrong pattern(for the parameter) please suggest me the right pattern.