我正在尝试从 spring session scoped bean 中获取 bean。据我所知,基于 session 范围实例化的 Beans 通过 HTTP session 存在。那么如何从 Http Session 中获取这个 bean 对象。
最佳答案
您可以访问 ApplicationContext 并从那里检索 bean。
ApplicationContext context = RequestContextUtils.getWebApplicationContext(request);
SessionInfo info = context.getBean("SessionInfo");-->Whatever bean you want
关于spring - 我们如何从 Spring session 范围的 bean 中获取 bean 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24593906/