天天看點

J2EE 加載Spring的applicationContext.xml檔案的兩種方式

1、在web.xml中加載:

    <context-param>

        <param-name>contextConfigLocation</param-name>

        <param-value>**/applicationContext.xml</param-value>

    </context-param>

    <listener>

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

    </listener>

2、在struts-config.xml中加載:

    <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">

        <set-property property="contextConfigLocation" value="**/applicationContext.xml" />

    </plug-in>