欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

获取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);

 

相关标签: springmvc spring