故意暂停JSP加载

时间:2016-02-09 11:21:58

标签: jsp

有没有办法故意暂停加载JSP页面?

我正在尝试以下内容......

<%
try
{
    String strWait = request.getParameter("wait");
    int iWait = 0;
    if (strWait != null || !strWait.isEmpty())
    {
       iWait = Integer.getInteger(strWait);
    }

    if (iWait > 0)
    {
       Thread.sleep(iWait);
    }
}
catch (Exception e) {}
%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
     </head>
    <body>
    ... etc....

用于填写更多文本和更少代码的愚蠢堆栈溢出要求的文本...

2 个答案:

答案 0 :(得分:0)

您可以使用javascript的setTimeout函数。

在您的情况下,只需将“等待”值传递给javascript函数,如下所示

functionToRunFirst();
setTimeout(function() {
    // rest of code here
}, 2000);

答案 1 :(得分:0)

对于任何其他人...此工作流程有效。我的问题是Integer.getInteger(strWait)电话。

这应该是Integer.parseInt(strWait)