1. 程式人生 > >第二章:理解DispatcherServlet ——深入淺出學Spring Web MVC

第二章:理解DispatcherServlet ——深入淺出學Spring Web MVC

整合Web環境的通用配置: <context-param>       <param-name>contextConfigLocation</param-name>       <param-value>           classpath:spring-common-config.xml,           classpath:spring-budget-config.xml       </param-value> </context-param> <listener>  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> 如上配置是Spring整合Web環境的通用配置;一般用於載入除Web層的Bean(如DAO、Service等),以便於與其他任何Web框架整合。 contextConfigLocation:表示用於載入Bean的配置檔案; contextClass:表示用於載入Bean的ApplicationContext實現類,預設WebApplicationContext。 建立完畢後會將該上下文放在ServletContext,如下:servletContext.setAttribute( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context);

相關推薦

no