项目中用到shiro管理权限,但是shiro在spring容器中,某些类不在spring中初始化,但是想得到spring容器管理的bean,或者从shiro中获取servletContext,如下
ServletRequest request = ((WebSubject)SecurityUtils.getSubject()).getServletRequest();
HttpSession httpSession = ((HttpServletRequest)request).getSession();
logger.debug("httpSession.getServletContext():"+httpSession.getServletContext());
context = WebApplicationContextUtils.getWebApplicationContext(httpSession.getServletContext());