【发布时间】:2016-01-11 08:41:10
【问题描述】:
我正在使用 ajax 调用来提交表单。 但我无法将参数作为模型属性访问。
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
});
我的疑问是,我能否像下面给定的代码一样将此参数作为模型属性访问。 ?
@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'}";
}
}
如果能听到一个很好的建议来解决我的疑问,我将非常感激。 如果这是错误的模式(对于参数),请建议我正确的模式。
【问题讨论】:
标签: javascript ajax spring spring-mvc parameters