系统架构前台用的是ajax请求,后台是mybites框架,excl导入大量数据时这两个架构都会报错,前台连接中断,后台参数过多,因为前台时间过长,后台参数过多,mybites一次请求最多存在2100个参数,所以前台要加timeout:
后台要截取一次性提交的参数数量:
private static final int EVERY_STEP = 50;
@Override
public boolean insertMaterial(Map map) {
List<ScmMaterial> scmmatList=null;/*new ArrayList<ScmMaterial>();*/
scmmatList=(List<ScmMaterial>) map.get("matList");
List<ScmMaterial> matList=null;
Map<String,Object> subMap = new HashMap<String,Object>();
int scm=0;
int scm2=0;
for(int i=0; i<scmmatList.size(); i=i+EVERY_STEP){
matList = scmmatList.subList(i, Math.min(scmmatList.size(), i+EVERY_STEP));//截取list长度供mybites处理
subMap.put("matList", matList);
scm = summaterialMapper.updateMaterial(subMap);
scm2 = summaterialMapper.updatejgAndkc(subMap);
}
if(scm>0&&scm2>0&&scm==scm2){
return true;
}
return false;
}