bootstrap-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);//将时间加入实体 } 前两种方法如果不好用 或者关联到其他方法不能使用 就将时间字段进行处理 cdtimev.ToDate() cdtimev是你在js里获取的时间 ToDate() 可以转化为时间类型 在conroller里就可以接到了(js获取的所有值都是String类型)