JSP处理消息 [英] JSP processing message

查看:62
本文介绍了JSP处理消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

probalby是一个很虚构的问题,但这不是我通常工作的领域...

probalby quite a dummy question, but that is not the area I work with usually...

我有一个html页面"start.html",该表单具有通过发布请求调用serverlet的形式.这个servlet(JSP)是action.java,我在那里:

I have html page "start.html" there is form which calls a serverlet via a post request. This servlet (JSP) is action.java there I have:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{
    //please show a message that I am working

    // here is some code which takes some time
    response.sendRedirect(http://result.html);


}

因此,我进行了一些处理,然后显示页面result.html.一切正常,问题在于,按下start.html中的发送按钮后,我只看到系统正在处理的IE中的这个小纺车,然后得到结果.大多数人可能会错过这个小指标.我想要一个中间页面或带有进度条,旋转轮的东西,甚至只显示一条消息请耐心等待".尽可能简单.我该如何实现?

So I do some processing then I show a page result.html. This all works fine, the problem is that upon pressing the send button in start.html I only see this little spinning wheel in IE that the system is processing and then I get the result. Most people probably would miss that little indicator. I would like to have an intermediate page or something with a progress bar, spinning wheel or even only a message "please be patient". As simple as possible. How can I achieve this?

谢谢!

推荐答案

只需将加载的动画gif放置在表单中,首先使用CSS将其隐藏,然后在提交表单时使用JavaScript将其显示出来.只要您不向HTTP响应中写入任何字节,当前页面在浏览器中的停留时间就不会消失.

Just put a loading animated gif in the form, initially hide it using CSS and then use JavaScript to show it up during submit of the form. As long as you don't write any byte to the HTTP response, the current page will just stick in the browser that long without going to blankout.

例如:

<form onsubmit="document.getElementById('loading').style.display='block'">
    ...

    <img id="loading" src="loading.gif" style="display: none;" />
</form>

(您实际上应该将此文件放在.js.css文件中)

(you should actually put this in a .js and .css file)

您可以从 Ajaxload.info 中获得一些漂亮的图像.

You can get yourself some nice images from Ajaxload.info.

这篇关于JSP处理消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆