1

我想将messsge显示为“请稍候......”,直到我的java代码完成一些处理。

page1.jsp - 我的表单,其中有文本框和提交按钮。当单击提交按钮时,我正在提交表单并调用 page2.jsp

在 page2.jsp 中,我从 page1.jsp 请求参数并传递给我的 java 方法,该方法返回我的用户 ID。

userid = myclass.mymethod(); 
if(userid!=null){ 
out.println("Record is in process.Please wait"); 
} 
response.sendredirect("page3.jsp?"+userid=userId); 

在 page3.jsp 中,我正在对同时在 page2.jsp 中获得的用户 ID 进行处理。

someid =request.getparameter(userid); 
process(someid ); 

但是在所有处理完成后会显示“等待”消息。我想在获得 userId 后立即显示它。并继续对该用户 ID 进行后台处理。

4

2 回答 2

1

你可以使用 javascript 做很多事情。这是一个想法。

<html>
<body>
<div id="wait">
Some text here is necessary here for the IE browser to start displaying. 
Otherwise it will wait until it receives enough of a response to begin displaying         anything.
I am not sure how much padding is necessary. This works in IE 8.
<%
  out.print("<little.gif' />");
  out.flush();
  for(int x = 0; x < 3; x++){
                         out.print("<br/>Processing!");
                         out.flush();
                         Thread.sleep(3000);  //mock processing
  }
%>
<br/></div>
<script>
  alert("Finished processing.");
  document.getElementById("wait").innerHTML = "Here are the results...";
</script>
</body>
</html>
于 2012-04-07T23:04:01.237 回答
0

我在 IE8 和 Chrome 18 中进行了测试。如果您的服务器有限制,那么您可能会遇到问题。例如,它不适用于 Google App Engine。

<html>
<body>
Some text here is necessary here for the IE browser to start displaying. 
Otherwise it will wait until it receives enough of a response to begin displaying      anything.
I am not sure how much padding is necessary. This works in IE 8.
<%
  out.print("<loading.gif' />");
  out.flush();
  //mock processing
  for(int x = 0; x < 3; x++){
                         out.print("<br/>Processing!");
                         out.flush();
                         Thread.sleep(3000);  
  }
%>
<br/>Finished processing. Here are the results...
</body>
</html>
于 2012-04-07T03:34:00.060 回答