Created
April 2, 2012 13:50
-
-
Save keesun/2283540 to your computer and use it in GitHub Desktop.
Spring 3.1's WebApplicationInitializer Sample
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
| public class SampleWebAppInitializer implements WebApplicationInitializer { | |
| @Override | |
| public void onStartup(ServletContext servletContext) throws ServletException { | |
| AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext(); | |
| // ac.register(AppConfig.java); | |
| ServletContextListener listener = new ContextLoaderListener(ac); | |
| servletContext.addListener(listener); | |
| AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); | |
| // ac.register(WebConfig.class); | |
| ServletRegistration.Dynamic dispatcher = servletContext.addServlet("spring", new DispatcherServlet(context)); | |
| dispatcher.setLoadOnStartup(1); | |
| dispatcher.addMapping("/app"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment