通过WebApplicationContextUtils工具类获取ApplicationContext对象.
通过WebApplicationContextUtils工具类获取ApplicationContext对象.
?
只需要传入application对象即可.
如果是struts2中通过如下方式获取application对象:
ServletContext application = ServletActionContext.getRequest().getSession().getServletContext();
?
?
以下是获取applicationContext对象;
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application);UserDao bd = (UserDao)context.getBean(spring中配置bean ID的名称);
?