使用Spring 2.5是否可以在不同的窗口选项卡中维护不同的会话(用户)?

使用Spring 2.5是否可以在不同的窗口选项卡中维护不同的会话(用户)?

问题描述:

我们有一个要求,即在浏览器窗口的不同选项卡中支持不同的用户.在Spring 2.5中如何实现呢?该应用程序基于用户,用户将在其中拥有自己的代理和文章.内部用户应能够同时登录不同选项卡中的不同用户帐户并处理其数据.非常感谢您的帮助.

We have a requirement where support for different users in different tabs of a browser window. How can we achieve this in Spring 2.5? The application is based on Users, where users will have their own agents and articles. An internal user should be able to login to different user accounts in different tabs at same time and manipulate their data. Any help is much appreciated.

浏览器的cookie存储库在决定发送哪些cookie时不会区分不同的窗口或选项卡.因此,基于cookie的方法将无济于事.

A browser's cookie store does not distinguish between different windows or tabs when deciding what cookies to send. So a cookie based approach won't help.

我对替代方法的建议是具有一个隐藏的"userName"参数,该参数作为给定选项卡或窗口中所有请求的URL查询参数来回传递.您可以通过使用一些Javascript在刚刚加载的页面中的每个HTML表单中添加一个隐藏的参数,来细化浏览器请求中的参数设置.该参数值将从当前页面URL的查询字符串中塞入.您只需要确保所有页面的标头中都包含内容,即可加载JS并在页面加载完成后运行它.

My suggestion for an alternative would be to have a hidden "userName" parameter that is passed back and forth as a URL query parameter for all requests from a given tab or window. You could finesse the setting of the parameter in browser requests by using some Javascript to add a hidden parameter to each of the HTML forms in the page just loaded. The parameter value would be snarffed from the query string of the current page URL. You'd just need to make sure that all pages included stuff in the header to load the JS and run it when the page load completed.