2 lr393993507 lr393993507 于 2014.01.02 09:11 提问

Extjs4表单提交问题????

//------------------添加按钮事件----------------------------------------------
gdgl_add_Item:function(button){
var cmpanel=button.up('globalStatisticsView');
var store = cmpanel.getStore();
var myWindow = Ext.create('Ext.window.Window',{
title:'增加联系人',
height: 300,
width: 450,
id:'add_window',
layout: 'form',
modal:true,
items: { // Let's put an empty grid in just to illustrate fit layout
xtype: 'form',
border: false,
layout: 'anchor',
defaults: {
anchor: '100%'
},
defaultType: 'textfield',
items: [{
fieldLabel: '故障时间',
name: 'failuretime',
xtype: 'datefield',
margin:10,
allowBlank:false
},{
fieldLabel: '故障地点',
name: 'failureaddress',
margin:10,
allowBlank: false
},{
fieldLabel: '维修时间',
name: 'repairtime',
xtype: 'datefield',
margin:10,
allowBlank: true
},{
fieldLabel: '维修人',
margin:10,
name: 'maintenanceman',
allowBlank: true
},{
fieldLabel: '完成情况',
margin:10,
name: 'completion',
allowBlank: true
},{
fieldLabel: '故障内容',
margin:10,
name: 'failurecontent',
allowBlank: true
}],
buttons: [ {
text: '增加',
formBind: true, //only enabled once the form is valid
disabled: true,
handler: function() {
var form = this.up('form').getForm();
var window =this.up('window');
Ext.Ajax.request({
url:'gdgl/addmanagers',
headers:{'Content-Type':'application/json;charset=utf-8'},
//params:Ext.JSON.encode(form.getValues())
// Ext.Msg.alert('增加成功',JSON.stringify(myWindow.getValues(),null,2));
params:Ext.JSON.encode(form.getValues())
});
}
},{
text: '取消',
handler: function() {
this.up('window').close();
}
}]
}
});
myWindow.show();
},

后台代码为SpringMVC,可是每次提交数据库都是空

@RequestMapping("/addmanagers")
@ResponseBody
public Map<String, Object>  addWorkOrders(WorkOrders workOrders){
    Map<String, Object> map = new HashMap<String, Object>();
    Message message = workOrdersService.addWorkOrders(workOrders);
    map.put("success",message.isMessageFlag());
    map.put("msg", message.getMessageName()+":"+message.getMessageText());
    return map;
}

为什么每次提交数据都是为空呢?我用的ajax请求提交数据有什么问题,
最主要的是我的model模型为什么datefield类型就是提交不上去呢?原来数据库字段类型都是string后来两个改为date类型后,Extjs就提交不上去了,请问是什么原因呢??

1个回答

jsjxieyang
jsjxieyang   2014.01.02 11:14

使用httpwatch或者其他工具 ,看看页面都提交了什么数据,不行的话,手动转换日期格式

Csdn user default icon
上传中...
上传图片
插入图片