Skip to content

Instantly share code, notes, and snippets.

@benhardy
Created November 18, 2012 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhardy/4103344 to your computer and use it in GitHub Desktop.
Save benhardy/4103344 to your computer and use it in GitHub Desktop.
webapp config
/**
* Our instance of WebApplicationInitializer. This replaces web.xml for the initial
* configuration of the servlet.
*/
class WebAppInit extends WebApplicationInitializer {
override def onStartup(servletContext: ServletContext) {
// Create the 'root' Spring application context
val root = new AnnotationConfigWebApplicationContext()
root.scan("skellybones")
// Manages the lifecycle of the root application context
servletContext.addListener(new ContextLoaderListener(root))
val servlet = new DispatcherServlet(root)
val appServlet = servletContext.addServlet("appServlet", servlet)
appServlet.setLoadOnStartup(1)
val mappingConflicts = appServlet.addMapping("/")
if (!mappingConflicts.isEmpty) {
throw new IllegalStateException("'appServlet' could not be mapped to '/'")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment