context-param之contextConfigLocation

contextConfigLocation参数定义了Spring项目启动的时候,需要装载的xml配置文件的位置。如果没有定义这个参数,那么Spring默认会去装载WEB-INF下的applicationContext.xml文件;否则就会按照该参数定义的属性值来装载相应的配置文件。

装载配置文件,还需要org.springframework.web.context.ContextLoaderListener类的配合,该类继承自ServletContextListener接口。如果只有一个配置文件,且文件名就是applicationContext,那么只需在web.xml文件中增加如下代码即可:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

 

参考:

http://taoyang168.blog.163.com/blog/static/12650506920123212056305/

posted on 2015-12-17 16:04  奈何作贼  阅读(184)  评论(0)    收藏  举报

导航