获取Spring的应用上下文ApplicationContext
程序员文章站
2022-05-23 10:19:40
...
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
ServletContext context = request.getSession().getServletContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
JavaBean bean = ctx.getBean(JavaBean.class);
上一篇: 获取Spring上下文已实例化的bean
下一篇: Spring Bean工厂和上下文