Created
November 4, 2011 14:36
-
-
Save igm/1339463 to your computer and use it in GitHub Desktop.
Spring 3.1 WebApplication Initialization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.servlet.ServletContext; | |
| import javax.servlet.ServletException; | |
| import javax.servlet.ServletRegistration.Dynamic; | |
| import org.springframework.web.WebApplicationInitializer; | |
| import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; | |
| import org.springframework.web.servlet.DispatcherServlet; | |
| public class ContextInitializer implements WebApplicationInitializer { | |
| public void onStartup(ServletContext servletContext) throws ServletException { | |
| AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); | |
| ctx.register(AppConfig.class); | |
| Dynamic servlet = servletContext.addServlet("dis", new DispatcherServlet(ctx)); | |
| servlet.setLoadOnStartup(1); | |
| servlet.addMapping("/"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment