Wednesday, November 2, 2016

How to activate Spring Container in Web Application?

One of the ways to Activate Spring 'ApplicationContext' container is
First Configure the Spring configuration file in web.xml file
eg:

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>WEB-INF/Spring.cfg.xml</param-value>
</context-param>


and next Configure the ContextLoaderListener

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


and finally in Servlet


ApplicationContext context=WebApplicationContextUtils.
    getRequiredWebApplicationContext(config.getServletContext());



It is done. Now ApplicationContext Container will be activated.
Share:

0 comments:

Post a Comment