施用web.xml方式加载Spring时,获取Spring context的两种方式

使用web.xml方式加载Spring时,获取Spring context的两种方式:1、servlet方式加载时:【ServletContext?contex

使用web.xml方式加载Spring时,获取Spring context的两种方式:

1、servlet方式加载时:

          ServletContext?context?=?getServletContext(); ??????? ?????WebApplicationContext?applicationContext??=?WebApplicationContextUtils ???????.getWebApplicationContext(context); ????? ????????DataSource?dataSource=(DataSource)applicationContext.getBean("dataSource");?