显示消息等待...当后台处理发生时

2023-12-06

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

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

在页面 2.jsp 中,我从页面 1.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就显示它。并继续对该 userId 进行后台处理。


你可以使用 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

显示消息等待...当后台处理发生时 的相关文章

随机推荐