|
@@ -1,6 +1,10 @@
|
|
|
package com.lovecoding.mvc;
|
|
|
|
|
|
+import com.lovecoding.mvc.config.SpringConfig;
|
|
|
+import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|
|
import org.springframework.web.WebApplicationInitializer;
|
|
|
+import org.springframework.web.context.WebApplicationContext;
|
|
|
+import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
|
|
import org.springframework.web.context.support.XmlWebApplicationContext;
|
|
|
import org.springframework.web.servlet.DispatcherServlet;
|
|
|
|
|
@@ -8,24 +12,32 @@ import javax.servlet.ServletContext;
|
|
|
import javax.servlet.ServletException;
|
|
|
import javax.servlet.ServletRegistration;
|
|
|
|
|
|
-public class Application implements WebApplicationInitializer {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onStartup(ServletContext servletContext) throws ServletException {
|
|
|
- System.out.println( "我被调用了!!!" );
|
|
|
-
|
|
|
- XmlWebApplicationContext applicationContext = new XmlWebApplicationContext();
|
|
|
-
|
|
|
- applicationContext.setConfigLocation("classpath:spring.xml");
|
|
|
-
|
|
|
- DispatcherServlet dispatcherServlet = new DispatcherServlet(applicationContext);
|
|
|
-
|
|
|
- ServletRegistration.Dynamic dispatcher =
|
|
|
- servletContext.addServlet("dispatcher", dispatcherServlet);
|
|
|
-
|
|
|
- dispatcher.setLoadOnStartup(1);
|
|
|
- dispatcher.addMapping("/");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+//public class Application implements WebApplicationInitializer {
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onStartup(ServletContext servletContext) throws ServletException {
|
|
|
+// //System.out.println( "我被调用了!!!" );
|
|
|
+//
|
|
|
+//// XmlWebApplicationContext applicationContext = new XmlWebApplicationContext();
|
|
|
+//// applicationContext.setConfigLocation("classpath:spring.xml");
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// AnnotationConfigWebApplicationContext applicationContext =
|
|
|
+// new AnnotationConfigWebApplicationContext();
|
|
|
+// applicationContext.register( SpringConfig.class );
|
|
|
+//
|
|
|
+// //配置 MVC 配置档
|
|
|
+// //配置 Mybatis配置档
|
|
|
+//
|
|
|
+// DispatcherServlet dispatcherServlet = new DispatcherServlet(applicationContext);
|
|
|
+//
|
|
|
+// ServletRegistration.Dynamic dispatcher =
|
|
|
+// servletContext.addServlet("dispatcher", dispatcherServlet);
|
|
|
+//
|
|
|
+// dispatcher.setLoadOnStartup(1);
|
|
|
+// dispatcher.addMapping("/");
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//}
|