Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.dm.platform.spring; import javax.servlet.ServletContext; import javax.servlet.ServletRegistration; import org.springframework.web.WebApplicationInitializer; import org.springframework.web.context.ContextLoaderListener; import org.springframework.web.context.support.XmlWebApplicationContext; import org.springframework.web.servlet.DispatcherServlet; public class MyWebApplicationInitializer //implements WebApplicationInitializer { // @Override public void onStartup(ServletContext container) { System.out.println("MyWebApplicationInitializer[onStartup]"); XmlWebApplicationContext ac = new XmlWebApplicationContext(); container.addListener(new ContextLoaderListener(ac)); // ServletRegistration.Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet()); // registration.setLoadOnStartup(1); // registration.addMapping("/spring/*"); } }