1.controller中获得webIoC容器
ServletContext context = request.getSession().getServletContext();
WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
ctx.getBean("menuTreeDao");
本文介绍了一种在controller中通过HttpServletRequest获取Web应用上下文的方法,并展示了如何使用WebApplicationContextUtils工具类来获取WebIoC容器,进而获取指定的bean实例。
1.controller中获得webIoC容器
ServletContext context = request.getSession().getServletContext();
WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
ctx.getBean("menuTreeDao");
703

被折叠的 条评论
为什么被折叠?