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"/>

posted @ 2010-12-20 21:56  左正  阅读(291)  评论(0编辑  收藏  举报