Code example for XmlWebApplicationContext

Methods: setConfigLocation

0
 */ 
public class WebAppInitializer implements WebApplicationInitializer { 
 
  @Override 
  public void onStartup(ServletContext container) { 
    XmlWebApplicationContext appContext = new XmlWebApplicationContext(); 
    appContext.setConfigLocation("/WEB-INF/applicationContext.xml"); 
 
    ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(appContext)); 
    dispatcher.setLoadOnStartup(1); 
    dispatcher.addMapping("/"); 
  } 
}