2

I am trying to implement a long polling mechanism for auto-updating a grid in a project that uses Spring MVC.

I am sending an Ajax request from the client and on the server side I enter a while loop until data is found then the data is send back as a response.

I need to have another mechanism that stops this operation (that breaks off the loop) when the user changes tab in the application (every tab has a different grid that is auto-updating through long polling. Every tab is handled server-side by a different controller).

What I thought is that I need to have a session scoped variable or bean that changes when the client changes tab and which is accessible from inside the loop so it can break on change. When I tried to use Spring MVC beans scope I noticed that the bean's property that I common in two different sessions (that is HttpSession). I tested this by loging in with a different user from the same machine.

I tried using the but I had the same result.

Any ideas on how to make this work?

Thank you in advance.

4

1 回答 1

0

Spring MVC 3.2(目前是一个里程碑版本)中引入了长轮询和其他异步进程。它可能值得一看,而不是尝试实现自己的解决方案。

http://blog.springsource.org/2012/05/13/spring-mvc-3-2-preview-adding-long-polling-to-an-existing-web-application/

于 2012-05-21T13:17:43.030 回答