今天准备搞一下ExtJs分页,从原来自己架构的网站上摘取下来的代码不知道什么原因,竟然加载不了spring的配置文件,很是郁闷。经过一番查找终于解决。现总结如下:

第一:在web.xml中配置如下

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

第二:在web.xml中配置如下

<context-param> 
  <param-name>contextConfigLocation</param-name> 
  <param-value>/WEB-INF/applicationContext-*.xml</param-value> 
</context-param> 
<servlet> 
  <servlet-name>SpringContextServlet</servlet-name> 
  <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> 
  <load-on-startup>1</load-on-startup> 
</servlet>

第三:在struts-config.xml文件中配置如下

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> 
 <set-property property="contextConfigLocation"  value="/WEB-INF/applicationContext.xml,/WEB-INF/action-servlet.xml"/> 
</plug-in>

经过一番稀里糊涂的折腾以后,利用第二种方法,终于大功告成。NND,作为社会主义初级阶段的高级Java开发工程师,这么个小事儿,竟然花费寡人如此多的宝贵时间,幸好在第二种方法的时候,能够搞定,想起来自己也真够2的。