Skip to content

Commit 86af93a

Browse files
committed
Correct sample in webmvc.adoc
Closes gh-25965
1 parent fb4363e commit 86af93a

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/docs/asciidoc/web/webmvc.adoc

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,15 @@ the `DispatcherServlet`, which is auto-detected by the Servlet container
4646
public class MyWebApplicationInitializer implements WebApplicationInitializer {
4747
4848
@Override
49-
public void onStartup(ServletContext servletCxt) {
49+
public void onStartup(ServletContext servletContext) {
5050
5151
// 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);
5554
5655
// 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);
5958
registration.setLoadOnStartup(1);
6059
registration.addMapping("/app/*");
6160
}
@@ -66,16 +65,15 @@ the `DispatcherServlet`, which is auto-detected by the Servlet container
6665
----
6766
class MyWebApplicationInitializer : WebApplicationInitializer {
6867
69-
override fun onStartup(servletCxt: ServletContext) {
68+
override fun onStartup(servletContext: ServletContext) {
7069
7170
// 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)
7573
7674
// 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)
7977
registration.setLoadOnStartup(1)
8078
registration.addMapping("/app/*")
8179
}

0 commit comments

Comments
 (0)