|
|
|
@ -46,16 +46,15 @@ the `DispatcherServlet`, which is auto-detected by the Servlet container |
|
|
|
public class MyWebApplicationInitializer implements WebApplicationInitializer { |
|
|
|
public class MyWebApplicationInitializer implements WebApplicationInitializer { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onStartup(ServletContext servletCxt) { |
|
|
|
public void onStartup(ServletContext servletContext) { |
|
|
|
|
|
|
|
|
|
|
|
// Load Spring web application configuration |
|
|
|
// Load Spring web application configuration |
|
|
|
AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext(); |
|
|
|
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); |
|
|
|
ac.register(AppConfig.class); |
|
|
|
context.register(AppConfig.class); |
|
|
|
ac.refresh(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create and register the DispatcherServlet |
|
|
|
// Create and register the DispatcherServlet |
|
|
|
DispatcherServlet servlet = new DispatcherServlet(ac); |
|
|
|
DispatcherServlet servlet = new DispatcherServlet(context); |
|
|
|
ServletRegistration.Dynamic registration = servletCxt.addServlet("app", servlet); |
|
|
|
ServletRegistration.Dynamic registration = servletContext.addServlet("app", servlet); |
|
|
|
registration.setLoadOnStartup(1); |
|
|
|
registration.setLoadOnStartup(1); |
|
|
|
registration.addMapping("/app/*"); |
|
|
|
registration.addMapping("/app/*"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -66,16 +65,15 @@ the `DispatcherServlet`, which is auto-detected by the Servlet container |
|
|
|
---- |
|
|
|
---- |
|
|
|
class MyWebApplicationInitializer : WebApplicationInitializer { |
|
|
|
class MyWebApplicationInitializer : WebApplicationInitializer { |
|
|
|
|
|
|
|
|
|
|
|
override fun onStartup(servletCxt: ServletContext) { |
|
|
|
override fun onStartup(servletContext: ServletContext) { |
|
|
|
|
|
|
|
|
|
|
|
// Load Spring web application configuration |
|
|
|
// Load Spring web application configuration |
|
|
|
val ac = AnnotationConfigWebApplicationContext() |
|
|
|
val context = AnnotationConfigWebApplicationContext() |
|
|
|
ac.register(AppConfig::class.java) |
|
|
|
context.register(AppConfig::class.java) |
|
|
|
ac.refresh() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create and register the DispatcherServlet |
|
|
|
// Create and register the DispatcherServlet |
|
|
|
val servlet = DispatcherServlet(ac) |
|
|
|
val servlet = DispatcherServlet(context) |
|
|
|
val registration = servletCxt.addServlet("app", servlet) |
|
|
|
val registration = servletContext.addServlet("app", servlet) |
|
|
|
registration.setLoadOnStartup(1) |
|
|
|
registration.setLoadOnStartup(1) |
|
|
|
registration.addMapping("/app/*") |
|
|
|
registration.addMapping("/app/*") |
|
|
|
} |
|
|
|
} |
|
|
|
|