Spring不更新Ajax轮询的会话 [英] Spring do not update session for ajax polling

查看:140
本文介绍了Spring不更新Ajax轮询的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们当前在我们的一个Spring Web应用程序上遇到会话超时问题.会话永远不会超时,因为我们有一个连续的ajax请求轮询服务器.有没有办法告诉spring忽略此请求而不更新会话,以便超时按预期工作?

We are currently running into a problem with session time outs on one of our Spring web applications. The session never times out because we have a continuous ajax request polling the server. Is there a way to tell spring to ignore this request and not update the session so that time out works as expected?

推荐答案

您可以运行一个等于会话超时的计时器,以及连续的ajax请求,如果页面永不刷新,该请求将注销用户.另一个想法是将您要访问的URL托管在同一域的单独的Web应用程序中.我不确定Spring是否为您的工作内置了一些东西.

You could run a timer, equal to your session timeout, along side the continuous ajax request that would log the user out if the page never refreshes. Another idea would be to host the URL that you are hitting in a separate web application on the same domain. I'm not sure if Spring has something built in for what you are doing.

我考虑了更多.您可以实现自己的会话注册表,而忽略Ajax URL.基本上,如果URL与您在忽略列表或Spring Security过滤器链中定义的过滤器中定义的URL匹配,则不会在会话注册表中为用户设置上次访问时间.

I thought about this some more. You could implement your own session registry that ignores the Ajax URLs. Basically you wouldn't set the last accessed time for a user in the session registry if the URL matched one that you defined in your ignore list or filter defined in the Spring Security filter chain.

请参见 查看全文

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