读书人

施用web.xml方式加载Spring时获取Sp

发布时间: 2012-10-19 16:53:36 作者: rapoo

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

1、servlet方式加载时:

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

读书人网 >Web前端

热点推荐