简体   繁体   English

使用 spring 安全性的会话属性

[英]Session Attributes using spring security

Could anyone help me?有人可以帮助我吗?

How can add session attributes if i am using spring security?如果我使用 Spring Security,如何添加会话属性?

Let me explain:让我解释:

When an user is logged, I want to create an object called Filters and other called Site当用户登录时,我想创建一个名为 Filters 和其他名为 Site 的对象

The aim of Filters object is to keep the different filters that the user can apply in a table. Filters 对象的目的是将用户可以应用的不同过滤器保留在表中。

The aim of Site object is to keep the site or place where the user works, to determine the info that can see in accordance of the Site. Site对象的目的是保留用户工作的站点或地点,根据站点确定可以看到的信息。

I tried to create private objects variables in the main controller, but when multiple user are logged, they share the variables我试图在主控制器中创建私有对象变量,但是当多个用户登录时,他们共享变量

Thanks谢谢

See this link .请参阅此链接

If you what to use HttpSession to store this information, you should get the user identity first in your Controller and use it as key when you store in the session(Concat information when key exist in the session).如果您使用HttpSession来存储此信息,您应该首先在您的Controller获取用户身份,并在您存储在会话中时将其用作密钥(会话中存在密钥时的连接信息)。 For example You can use this link .例如,您可以使用此链接

I tried to create private objects variables in the main controller, but when multiple user are logged, they share the variables我试图在主控制器中创建私有对象变量,但是当多个用户登录时,他们共享变量

For the above issue, I would recommend you to put session attribute detail with the key as user_id which is unique for each user so once the user is logged in you can get the details (session attribute value) with user id.对于上述问题,我建议您将会话属性详细信息与密钥作为 user_id 放置,这对每个用户都是唯一的,因此一旦用户登录,您就可以使用用户 ID 获取详细信息(会话属性值)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM