Spring provides three implementations for ApplicationContext: ClassPathXmlApplicationContext, FileSystemXmlApplicationContext, and XmlWebApplicationContext. XmlWebApplicationContext is designed for Web engineering. Example:
1. FileSystemXmlApplicationContext
Eg1.ApplicationContext ctx = new FileSystemXmlApplicationContext ("bean. xml"); // load a single configuration file
Eg2.String [] locations = {"bean1.xml", "bean2.xml", "bean3.xml"}; ApplicationContext ctx = new FileSystemXmlApplicationContext (locations); // load multiple configuration files
Eg3. ApplicationContext ctx = new FileSystemXmlApplicationContext ("D: roject/bean. xml"); // load the file according to the specific path
2. ClassPathXmlApplicationContext
eg1. ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml");
Eg2.String [] locations = {"bean1.xml", "bean2.xml", "bean3.xml"}; ApplicationContext ctx = new ClassPathXmlApplication (locations); note: among them, FileSystemXmlApplicationContext and ClassPathXmlApplicationContext are path-based in the same way as the xml file of BeanFactory.
3. XmlWebApplicationContext
eg1.ServletContext servletContext = request.getSession().getServletContext(); ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);