File tree Expand file tree Collapse file tree
spring-all/src/main/java/org/baeldung/controller/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111import org .springframework .web .servlet .DispatcherServlet ;
1212
1313public class StudentControllerConfig implements WebApplicationInitializer {
14+
15+ @ Override
16+ public void onStartup (ServletContext sc ) throws ServletException {
17+ AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext ();
18+ root .register (WebConfig .class );
1419
20+ root .setServletContext (sc );
1521
16- @ Override
17- public void onStartup (ServletContext sc ) throws ServletException {
18- AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext ();
19- root .register (WebConfig .class );
20-
21- root .refresh ();
22- root .setServletContext (sc );
23-
24- // Manages the lifecycle of the root application context
25- sc .addListener (new ContextLoaderListener (root ));
26-
27-
28-
29- DispatcherServlet dv =new DispatcherServlet (new GenericWebApplicationContext ());
30-
31- ServletRegistration .Dynamic appServlet = sc .addServlet ("test-mvc" ,dv );
32- appServlet .setLoadOnStartup (1 );
33- appServlet .addMapping ("/test/*" );
34- }
22+ // Manages the lifecycle of the root application context
23+ sc .addListener (new ContextLoaderListener (root ));
3524
36- }
25+ DispatcherServlet dv = new DispatcherServlet ( new GenericWebApplicationContext ());
3726
27+ ServletRegistration .Dynamic appServlet = sc .addServlet ("test-mvc" , dv );
28+ appServlet .setLoadOnStartup (1 );
29+ appServlet .addMapping ("/test/*" );
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments