Java Web App FutureTask进度栏 [英] Java Web App FutureTask Progress Bar

查看:66
本文介绍了Java Web App FutureTask进度栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java Web应用程序,它通过struts动作执行长时间运行的任务.我想显示任务的进度条,并希望通过AJAX更新进度条,该AJAX调用一些操作以获取正在运行的线程的当前进度.

I have a Java web application that performs a long running task via a struts action. I would like to display a progress bar for the task and would like to update the progress bar via AJAX which calls some action to get the current progress of the running thread.

完成此操作的最佳实践是什么?如果操作A执行FutureTask线程,如何从另一个操作访问此FutureTask对象以获取其当前进度?甚至有可能解决这个问题吗?

What is the best practice for accomplishing this? If action A executes the FutureTask thread, how do I access this FutureTask object from another action to get its current progress? Is this even possible or is there a better approach to this problem?

任何帮助将不胜感激.

谢谢!

推荐答案

将FutureTask或Callable放入会话中,然后在其他操作中将其拉出以检查进度.

Put the FutureTask or the Callable in the Session and then pull it out in the other action to check the progress.

这篇关于Java Web App FutureTask进度栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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