首先只写2种以后会逐步完善其他几种加载方式
方式1:在web.xml里面加载
<!-- 加载spring配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
spring配置文件名为beans.xml
方式2:在struts.xml里面加载
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="classpath:beans.xml" />
</plug-in>
本文介绍了两种在Web应用中加载Spring配置文件的方法:通过web.xml中的ContextLoaderListener和struts.xml中的ContextLoaderPlugIn插件进行加载。这些方法使得Spring框架能够更好地与Web应用集成。
6754

被折叠的 条评论
为什么被折叠?



