使用 getSomethingWithAjax 发送的数据有浏览器限制,我想知道如果我想发布大数据,用什么代替 getSomethingWithAjax()?这是我的代码:此代码在 textarea 中打开一个文本文件并允许用户输入或删除字符,在发送大约 2800 个字符时有限制。
<%
if(request.getParameter("thetext") != null) {
File savedHere = new File(request.getParameter("filepath"));
FileOutputStream out2 = new FileOutputStream(savedHere);
PrintStream p = new PrintStream(out2);
try {
boolean gotError = false;
if(request.getParameter("revert").equals("1")) {
System.out.println("In revert");
p.print(request.getParameter("thetextRev").replace("\r",""));
gotError = p.checkError();
p.close();
} else {
System.out.println("NOT in revert\n"+request.getParameter("thetext"));
p.print(request.getParameter("thetext").replace("\r",""));
gotError = p.checkError();
p.close();
}
if(request.getParameter("revert").equals("0")) {
if(!gotError) {
out.println("File was successfully modified");
} else {
out.println("Error while writing the file");
}
}
}
catch(Exception ex) {
System.out.println("Exception while trying to write out to file");
out.println("There was an error while writing file");
}
}
String filename = "";
java.lang.StringBuffer myStuff = new java.lang.StringBuffer(100000);
if(request.getParameter("STEP")!=null
&& request.getParameter("secret")!=null
&& !request.getParameter("secret").equals("yes")) {
filename = request.getParameter("autoFiles");
File chosenFile = new File(filename);
DataInputStream dis = new DataInputStream(new FileInputStream (chosenFile));
String data = null;
while((data = dis.readLine()) != null) {
myStuff.append(data+"\n");
}
//this is just to check capacity and current length of file
out.println("Capacity is:"+ myStuff.capacity()+ "characeter count is" +
myStuff.length());
%>
<br>
<form method="POST" class="example" action="/jsp/EditText.jsp" id=form2>
<input type=hidden name=filepath value="<%=filename%>">
<input type=hidden name=revert id=revert value="0">
<input type=hidden name=textarea value=true>
<br>
<center>
<textarea class="form-textarea resizable" id="textarea" style="width:90%;height:27em;
font-family:courier;font-size:14;"
name="thetext"><%=myStuff.toString()%></textarea>
<div style="display:none;">
<textarea id="textareaRev" style="width:90%;height:27em; font-family:courier;font-
size:14;"name="thetextRev"><%=myStuff.toString()%></textarea>
</div>
<br><br>
<input type=button name=submit value="Save Changes"
onClick="if(runOnSubmit(){
getSomethingWithAjax('EditText.jsp'+
getAllFormElementsAndMakeIntoURI(true),'','hereIsTheMainHeaderSpan',false,false);}">
<input type=button name=submitRev value="Cancel/Exit"
onClick="toggleTextRevert();
getSomethingWithAjax('EditText.jsp','','hereIsTheMainHeaderSpan')">
<%
} else {
//initial part here, not relevant
/*
this part sorts a list of files located in a specific directory in a
dropdown menu Auto files is the generated files from the dropdown menu
*/
}
%>