阿贾克斯长轮询在Java中,Spring MVC的 - 会话范围的问题 [英] Ajax Long Polling in Java, Spring MVC - session scope issue

查看:252
本文介绍了阿贾克斯长轮询在Java中,Spring MVC的 - 会话范围的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个长轮询机制自动更新在使用Spring MVC的一个项目,一个网格。

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

我发送的客户端和服务器端我进入一个while循环,一个Ajax请求,直到找到数据然后将数据发送回一个响应。

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).

我的想法是,我需要有一个会话范围的变量或蚕豆,当客户端更改标签,这是从循环中访问,以便它可以在间隔变化而变化。当我试图使用Spring MVC豆范围我注意到,bean的属性,我在两个不同的会话共同的(即HttpSession中)。我与来自同一台机器不同的用户测试这个由登录电子。

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?

感谢你在前进。

推荐答案

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

Long polling and other async processes are being introduced in Spring MVC 3.2 (currently a milestone release). It might be worth a look rather than trying to implement your own solution.

<一个href="http://blog.springsource.org/2012/05/13/spring-mvc-3-2-$p$pview-adding-long-polling-to-an-existing-web-application/" rel="nofollow">http://blog.springsource.org/2012/05/13/spring-mvc-3-2-$p$pview-adding-long-polling-to-an-existing-web-application/

这篇关于阿贾克斯长轮询在Java中,Spring MVC的 - 会话范围的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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