码迷,mamicode.com
首页 > 编程语言 > 详细

Spring 环境搭建

时间:2015-10-31 22:52:05      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

一、需要的Jar包

技术分享

二、web.xml 配置文件的修改

spring有三种启动方式,使用ContextLoaderServlet,ContextLoaderListener和ContextLoaderPlugIn,
spring3.0及以后版本中已经删除ContextLoaderServlet 和Log4jConfigServlet,
可以采用余下两种启动方式ContextLoaderListener和ContextLoaderPlugIn,
建议使用ContextLoaderListener。

第一种

  1. <!--推荐使用此种方式-->
  2. <listener>
  3. <listener-class>
  4. org.springframework.web.context.ContextLoaderListener
  5. </listener-class>
  6. </listener>
  7. <!--contextConfigLocation在 ContextLoaderListener类中的默认值是 /WEB-INF/applicationContext.xml-->
  8. <context-param>
  9. <param-name>contextConfigLocation</param-name>
  10. <param-value>/WEB-INF/applicationContext.xml</param-value>
  11. <!-- <param-value>classpath:applicationContext*.xml</param-value> -->
  12. </context-param>

第二种

  1. <servlet>
  2. <servlet-name>context</servlet-name>
  3. <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
  4. <load-on-startup>1</load-on-startup>
  5. </servlet>

第三种

  1. <!--要导入org.springframework.web.struts-3.0.5.RELEASE.jar包,在struts2.0及以后版本不支持此种方式加载spring-->
  2. <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
  3. <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
  4. </plug-in>

Spring 环境搭建

标签:

原文地址:http://www.cnblogs.com/kesar/p/4926289.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!