2013-05-07 84 views
0

实际上,我正在开发一个使用Spring MVC的应用程序,在一种情况下,我必须让用户通过显示页面来等待结果。一旦后端处理请求结果将被加载。任何人都可以请告诉我,我该如何实现这一目标?在处理Spring中的请求之前显示等待页面

回答

1

我会说这是一个JavaScript解决方案,而不是一个春天的更多。

假设您正在等待后端进程的请求,您可以使用解决方案here等待响应,而后端生成所需的数据。

下面的代码会显示loaderImage id内的代码(假设它是HTML中的div),然后在成功加载时隐藏它。 ajax请求只是用于发送到后端控制器的任何POST或GET。

$('#loaderImage').show(); 
$.ajax({ 
    // Other ajax parameters 
    success: function() { 
     // hiding the image here 
     $('#loaderImage').hide(); 
    } 
}); 
+0

其实有也应超时显示page..the情况是这样的。 1)首先用户输入登录数据并提交。2)在处理完请求后,它应该在后端加载一个当前状态为3)的页面,它应该重定向到带有输出的浏览器。 – user503285 2013-05-07 14:48:37

+0

好的 - 所以在后端你想指定一个超时?我希望Spring能够为ajax返回一个新的视图来重定向到。如果你想指定一个服务器端超时,我建议使用Spring Security的内置功能http://stackoverflow.com/questions/12082677/setting-session-timeout-in-spring-mvc – david99world 2013-05-07 14:59:57

0

您可以使用

window.onload(); 


<!doctype html> 
<html> 
    <head> 
    <title>onload test</title> 
    <script> 
     function load() { 
     alert("load event detected!"); 
     } 
     window.onload = load; 
    </script> 
    </head> 
    <body> 
    <p>The load event fires when the document has finished loading!</p> 
    </body> 
</html> 

所以你可以删除你的加载股利或HTML。

https://developer.mozilla.org/en-US/docs/DOM/window.onload

相关问题