controller.astudent.StudentC
addStudent : function(button){//添加保存
var me = this;var win = button.up('window'), form = win.down('form').getForm();
var grid=this.getStudentVRef().grid;
if (form.isValid()) {
form.submit({
url:win.url,
params : {
btimes : win.down('datefield[name=btimes]').getValue(),
endTimes:win.down('datefield[name=endTimes]').getValue()
},
success : function(form, action) {
Ext.Msg.alert('信息提示', action.result.data);
if(action.result.success){
win.close();
grid.store.load();
}
},
failure : function(form, action) {
Ext.Msg.alert('提示', action.result.data);
}
});
}
},
===========================
添加页面
{xtype : 'datefield',fieldLabel : '开学时间',name : 'btimes',//时间不能和实体类时间一样
format:'Y-m-d H:i:s',//altFormats: 'Y-m-d'
},
=====================
后台controller
@RequestMapping("addStudent")
@ResponseBody
public Msg addStudent(Student student,@RequestParam("btimes") String btimes,@RequestParam("endTimes") String endTimes){
try {
student.setBtime(HStringUtil.getDateFstr(btimes));
student.setEtime(HStringUtil.getDateFstr(endTimes));
student.setCreated(new Date());
student.setCreater(SystemUtils.getUserContext().getUser().getUserName());
proheadService.add(student);
} catch (Exception e) {
e.printStackTrace();
return fail(e.getMessage());
}
return success("添加成功");
}