@@ -46,16 +46,15 @@ the `DispatcherServlet`, which is auto-detected by the Servlet container
46
46
public class MyWebApplicationInitializer implements WebApplicationInitializer {
47
47
48
48
@Override
49
- public void onStartup(ServletContext servletCxt ) {
49
+ public void onStartup(ServletContext servletContext ) {
50
50
51
51
// Load Spring web application configuration
52
- AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext();
53
- ac.register(AppConfig.class);
54
- ac.refresh();
52
+ AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
53
+ context.register(AppConfig.class);
55
54
56
55
// Create and register the DispatcherServlet
57
- DispatcherServlet servlet = new DispatcherServlet(ac );
58
- ServletRegistration.Dynamic registration = servletCxt .addServlet("app", servlet);
56
+ DispatcherServlet servlet = new DispatcherServlet(context );
57
+ ServletRegistration.Dynamic registration = servletContext .addServlet("app", servlet);
59
58
registration.setLoadOnStartup(1);
60
59
registration.addMapping("/app/*");
61
60
}
@@ -66,16 +65,15 @@ the `DispatcherServlet`, which is auto-detected by the Servlet container
66
65
----
67
66
class MyWebApplicationInitializer : WebApplicationInitializer {
68
67
69
- override fun onStartup(servletCxt : ServletContext) {
68
+ override fun onStartup(servletContext : ServletContext) {
70
69
71
70
// Load Spring web application configuration
72
- val ac = AnnotationConfigWebApplicationContext()
73
- ac.register(AppConfig::class.java)
74
- ac.refresh()
71
+ val context = AnnotationConfigWebApplicationContext()
72
+ context.register(AppConfig::class.java)
75
73
76
74
// Create and register the DispatcherServlet
77
- val servlet = DispatcherServlet(ac )
78
- val registration = servletCxt .addServlet("app", servlet)
75
+ val servlet = DispatcherServlet(context )
76
+ val registration = servletContext .addServlet("app", servlet)
79
77
registration.setLoadOnStartup(1)
80
78
registration.addMapping("/app/*")
81
79
}
0 commit comments