javaweb获取ApplicationContext对象

来源:互联网 发布:淘宝买组装机 编辑:程序博客网 时间:2024/05/24 07:12

1.

ApplicationContext ac = newClassPathXmlApplicationContext("spring-servlet.xml");

2.

ServletContext servletContext=request.getSession().getServletContext();               

ApplicationContext ac=WebApplicationContextUtils.getWebApplicationContext(servletContext); 

3.

WebApplicationContext ac=ContextLoader.getCurrentWebApplicationContext();


2 0