Skip to content

Instantly share code, notes, and snippets.

@letenkov
Created January 9, 2014 08:54
Show Gist options
  • Save letenkov/8331324 to your computer and use it in GitHub Desktop.
Save letenkov/8331324 to your computer and use it in GitHub Desktop.
public class AppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(javax.servlet.ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
appContext.register(AppConfig.class);
servletContext.addListener(new ContextLoaderListener(appContext));
AnnotationConfigWebApplicationContext webConfig = new AnnotationConfigWebApplicationContext();
webConfig.register(WebConfig.class);
ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(webConfig));
servlet.setLoadOnStartup(1);
servlet.addMapping("/*");
FilterRegistration.Dynamic csrfTokenGeneratorFilter = servletContext.addFilter("csrfTokenGeneratorFilter", CsrfTokenGeneratorFilter.class);
csrfTokenGeneratorFilter.addMappingForUrlPatterns(null, false, "/*");
FilterRegistration.Dynamic springSecurityFilterChain = servletContext.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class);
springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*");
FilterRegistration.Dynamic hiddenHttpMethodFilter = servletContext.addFilter("hiddenHttpMethodFilter", HiddenHttpMethodFilter.class);
hiddenHttpMethodFilter.addMappingForUrlPatterns(null, false, "/*");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment