读书人

web项目中加载spring器皿的方式

发布时间: 2012-07-26 12:01:08 作者: rapoo

web项目中加载spring容器的方式

1、在Web.xml中,通过ContextLoaderListener加载

?
<context-param>

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

??? <param-value>/WEB-INF/daoContext.xml /WEB-INF/applicationContext.xml</param-value>

</context-param>

<listener>

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

</listener>

?

2、在Web.xml中,通过ContextLoaderServlet加载


<context-param>

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

??? <param-value>/WEB-INF/daoContext.xml /WEB-INF/applicationContext.xml</param-value>

</context-param>

<servlet>

??? <servlet-name>context</servlet-name>

??? <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>

??? <load-on-startup>1</load-on-startup>

</servlet>


3、在struts-config.xml中,通过ContextLoaderPlugIn加载


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

??? <set-property property="contextConfigLocation" value="/WEB-INF/action-servlet.xml,

??????? /WEB-INF/applicationContext.xml"/>

</plug-in>

?

读书人网 >Web前端

热点推荐