Merge branch 'master' into eclipse-specific-files-removed
# Conflicts: # spring-all/src/main/java/org/baeldung/controller/config/StudentControllerConfig.java
This commit is contained in:
commit
e21f62fbcf
@ -1,33 +1,31 @@
|
|||||||
package org.baeldung.controller.config;
|
package org.baeldung.controller.config;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.ServletRegistration;
|
||||||
|
|
||||||
import org.springframework.web.WebApplicationInitializer;
|
import org.springframework.web.WebApplicationInitializer;
|
||||||
import org.springframework.web.context.ContextLoaderListener;
|
import org.springframework.web.context.ContextLoaderListener;
|
||||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
import org.springframework.web.context.support.GenericWebApplicationContext;
|
import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||||
import org.springframework.web.servlet.DispatcherServlet;
|
import org.springframework.web.servlet.DispatcherServlet;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.ServletRegistration;
|
|
||||||
|
|
||||||
public class StudentControllerConfig implements WebApplicationInitializer {
|
public class StudentControllerConfig implements WebApplicationInitializer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartup(ServletContext sc) throws ServletException {
|
||||||
|
AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
|
||||||
|
root.register(WebConfig.class);
|
||||||
|
|
||||||
|
root.setServletContext(sc);
|
||||||
|
|
||||||
@Override
|
// Manages the lifecycle of the root application context
|
||||||
public void onStartup(ServletContext sc) throws ServletException {
|
sc.addListener(new ContextLoaderListener(root));
|
||||||
AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
|
|
||||||
root.register(WebConfig.class);
|
|
||||||
|
|
||||||
root.refresh();
|
DispatcherServlet dv = new DispatcherServlet(new GenericWebApplicationContext());
|
||||||
root.setServletContext(sc);
|
|
||||||
|
|
||||||
sc.addListener(new ContextLoaderListener(root));
|
ServletRegistration.Dynamic appServlet = sc.addServlet("test-mvc", dv);
|
||||||
|
appServlet.setLoadOnStartup(1);
|
||||||
DispatcherServlet dv = new DispatcherServlet(new GenericWebApplicationContext());
|
appServlet.addMapping("/test/*");
|
||||||
|
}
|
||||||
ServletRegistration.Dynamic appServlet = sc.addServlet("test-mvc", dv);
|
|
||||||
appServlet.setLoadOnStartup(1);
|
|
||||||
appServlet.addMapping("/test/*");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user