I need to submit a form with a hudge params number, and I'm not allowed to modify the maxParameterCount in my tomcat.
我需要提交一个带有hudge params编号的表单,并且我不允许在我的tomcat中修改maxParameterCount。
So I decided to cut my forms data in parts, and submit them one by one.
所以我决定将我的表格数据分成几部分,然后逐一提交。
I try to submit the first 10 rows, and then 10 next rows and so on.
我尝试提交前10行,然后提交10行,依此类推。
But when the form is supposed to sumbit, nothing happen, the loop continues, and finally my form is still submited with all rows... Part of my code :
但是当表单应该是sumbit,没有任何反应时,循环继续,最后我的表单仍然提交所有行...我的部分代码:
var valuesOriginal = new Map();
var valuesEdited = new Map();
var valuesBackup = new Map();
$.each($('#zgImport').serializeArray(), function(i, field) {
if(field.name.substring(0,13) == "userLinesAuto"){
valuesEdited.set(field.name, field.value);
}else if (field.name.substring(0,17) == "userLinesOriginal"){
valuesBackup.set(field.name, field.value);
}else if (field.name.substring(0,9) == "userLines"){
valuesOriginal.set(field.name, field.value);
}
});
var totalRows = valuesOriginal.size;
$('[id^="userLines"]').attr("disabled", "disabled"); // empty form from userLines
var i =0;
var j=0;
var fieldsNumber = 14;
var rowPerSubmit = 3;
var submitNumber = Math.ceil((totalRows / fieldsNumber)/rowPerSubmit);
var currentRowNumber =0;
var cptAddedParams = 0;
var mapIter = valuesOriginal.entries();
var fieldPerSubmit = rowPerSubmit*fieldsNumber;
var currentField;
while(j<submitNumber){ // submiting several times
alert("new form");
while(cptAddedParams < fieldPerSubmit){ //Add params to form
currentField = mapIter.next().value;
var input = $("<input>").attr("type", "hidden").attr("name", currentField[0]).val(valuesOriginal.get(currentField[0]));
$('#zgImport').append($(input));
cptAddedParams++;
}
cptAddedParams =0;
j++;
alert("submiting");
jQuery("#zgImport").submit(function(){
alert("Submitted");
}); // submiting partial form
$('[id^="userLines"]').attr("disabled", "disabled"); // empty form from userLines
}
I get the "Submitted" alert only 1 time (in my test I get 20 rows so I should have it twice), and I see in debug in my java code that the controller's method is called only 1time with all form rows.
我只获得了“提交”警报一次(在我的测试中我得到20行所以我应该有两次),我在调试中看到我的java代码中控制器的方法仅在所有表单行中调用1次。
It seems that jquery waits for the 2nd sumbit() to actually submit the form.
似乎jquery等待第二个sumbit()实际提交表单。
1 个解决方案
#1
Or, just submit 1 parameter criteria
in the uri...then that parameter is a string
and you send a JSON object...you then deserialize it on the server side...
或者,只需在uri中提交1个参数条件...然后该参数是一个字符串,您发送一个JSON对象...然后在服务器端反序列化它...
1 object parameter
1个对象参数
#1
Or, just submit 1 parameter criteria
in the uri...then that parameter is a string
and you send a JSON object...you then deserialize it on the server side...
或者,只需在uri中提交1个参数条件...然后该参数是一个字符串,您发送一个JSON对象...然后在服务器端反序列化它...
1 object parameter
1个对象参数