
课程咨询: 400-996-5531 / 投诉建议: 400-111-8989
认真做教育 专心促就业
昆明达内培训的小编这一期给大家讲bootstropt-table大量字段整体表单上传之时间处理。
js中用$('#addUserForm').serialize(),//获取表单中所有数据传送到前台(controller)$.ajax({ type : "POST", url : $.el.Register.AppUrl + "path", data :$('#addUserForm').serialize(),//获取表单中所有数据dataType : 'json', async : false, success : function(msg) { }, error : function(error) { } });这时如果表单中有时间类型因为传过来的都是字符串类型所以前台(实体)的时间类型接不到解决方法:(1)可在entity实体里字段上加@DateTimeFormat(pattern = "yyyy-MM-dd")(2)在controller中用个String接这个变量(不能和字段名重名)转化为时间类型再用就可以了public String addTask(User user(实体对象),String dateStr(用于接时间)) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); ParsePosition pos = new ParsePosition(0); Date date = sdf.parse(dateStr,pos); gzrw.setEndtime(date);//将时间加入实体}