首先只写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>