简体   繁体   English

拦截session如何获取属性?

[英]How intercept session get attribute?

I was trying to implement persistence for sessions.我试图为会话实现持久性。 I want to basically store the session data in a db and currently I'm using HttpSessionAttributeListener to store value in db when a new session is created.我想基本上将 session 数据存储在数据库中,目前我正在使用 HttpSessionAttributeListener 在创建新的 session 时将值存储在数据库中。

I want to know how to retrieve the session from database ie how do I override the getSession attribute to retrieve from database.我想知道如何从数据库中检索 session,即如何覆盖 getSession 属性以从数据库中检索。

Try to pass a parameter of type HttpSession to your controller.尝试将 HttpSession 类型的参数传递给您的 controller。

Then access it using:然后使用以下方式访问它:

session.getAttribut(atr)

And modify it using并使用修改它

session.setAttribut(atr,"value")

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

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