<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/classes/service.bean.xml WEB-INF/classes/codeexamples.bean.xml </param-value>
</context-param>
你可以配置多个spring配置文件用空格分割
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/classes/service.bean.xml WEB-INF/classes/codeexamples.bean.xml </param-value>
</context-param>
你可以配置多个spring配置文件用空格分割
<param-name>contextConfigLocation</param-name>
<param-value> /WEB-INF/applicationContext-database.xml,
/WEB-INF/applicationContext-ibatis.xml,
/WEB-INF/applicationContext-service.xml </param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
及
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>
注意:推荐把所有的Spring配置文件都以applicationContext开头命名.这样通过/WEB-INF/applicationContext*.xml就可让Spring载入所需的配置xml了.
在你的Action中:
....
ServletContext servletContext=this.getServlet().getServletContext();
ApplicationContext context=WebApplicationContextUtils.getWebApplicationContext(servletContext);
YourBean bean=context.getBean("..........");
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/classes/service.bean.xml WEB-INF/classes/codeexamples.bean.xml </param-value>
</context-param>
是用逗号分开的。