Skip to content

Commit 53467b3

Browse files
committed
Adding the application configuration file
1 parent 5f272d5 commit 53467b3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package modisefileupload.java.config;
2+
3+
import javax.servlet.ServletContext;
4+
import javax.servlet.ServletException;
5+
import javax.servlet.ServletRegistration;
6+
7+
import org.springframework.web.WebApplicationInitializer;
8+
import org.springframework.web.context.ContextLoaderListener;
9+
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
10+
import org.springframework.web.servlet.DispatcherServlet;
11+
12+
public class WebAppInitializer implements WebApplicationInitializer{
13+
14+
@Override
15+
public void onStartup(ServletContext container) throws ServletException {
16+
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
17+
rootContext.register(WebConfig.class);
18+
container.addListener(new ContextLoaderListener(rootContext));
19+
DispatcherServlet dispatcherServlet = new DispatcherServlet(rootContext);
20+
ServletRegistration.Dynamic registration = container.addServlet("dispatcherServlet", dispatcherServlet);
21+
registration.setLoadOnStartup(1);
22+
registration.addMapping("/");
23+
}
24+
25+
}

0 commit comments

Comments
 (0)