web 加载spring有几种方式

1
<listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
         <param-name>contextConfigLocation</param-name>
         <param-value>/WEB-INF/classes/applicationContext.xml /WEB-INF/classes/a.xml</param-value>
</context-param>

ApplicationContext ctx=WebApplicationContextUtils.getWebApplicationContext();
         LoginAction action=(LoginAction)ctx.getBean("action");
2
String sp[]={"applicationContext.xml","a.xml"};
ApplicationContext ctx=new ClassPathXmlApplicationContext(sp);
3
ApplicationContext ctx=new ClassPathXmlApplicationContext("a*.xml");
4
<import resource="services.xml"/>

原文地址:https://www.cnblogs.com/soundcode/p/1911894.html