您的位置:首页 > 编程语言 > Java开发

加载spring配置文件的常用三种方法

2013-03-08 22:52 609 查看
http://weijie.blog.51cto.com/340746/66502
1方法(web.xml)
<web-app>

<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-app>
2方法(web.xml)
<web-app>

<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>
</web-app>
3方法在(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>
本文出自 “魏杰的技术专栏” 博客,请务必保留此出处http://weijie.blog.51cto.com/340746/66502
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  xml spring 配置文件