no xml support

This commit is contained in:
eugenp 2013-07-26 12:00:19 +03:00
parent 813295c4d1
commit abb54b915c
3 changed files with 34 additions and 52 deletions

View File

@ -1,31 +0,0 @@
package org.baeldung.servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
public class WebApp implements WebApplicationInitializer {
public WebApp() {
super();
}
// API
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
root.setServletContext(servletContext);
root.scan("org.baeldung.spring");
root.refresh();
final Dynamic servlet = servletContext.addServlet("mvc", new DispatcherServlet(root));
servlet.setLoadOnStartup(1);
servlet.addMapping("/");
}
}

View File

@ -0,0 +1,29 @@
package org.baeldung.servlet;
import org.baeldung.spring.ClientWebConfig;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
public class WebAppNew extends AbstractAnnotationConfigDispatcherServletInitializer {
public WebAppNew() {
super();
}
// API
@Override
protected Class<?>[] getRootConfigClasses() {
return null;
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class<?>[] { ClientWebConfig.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}

View File

@ -1,9 +1,9 @@
package org.baeldung.servlet;
//public class WebApp implements WebApplicationInitializer {
//
//public class NewWebApp extends AbstractAnnotationConfigDispatcherServletInitializer {
//
// public NewWebApp() {
// public WebApp() {
// super();
// }
//
@ -18,23 +18,7 @@ package org.baeldung.servlet;
//
// final Dynamic servlet = servletContext.addServlet("mvc", new DispatcherServlet(root));
// servlet.setLoadOnStartup(1);
// servlet.addMapping("/*");
// servlet.addMapping("/");
// }
//
// @Override
// protected Class<?>[] getRootConfigClasses() {
// return null;
// }
//
// @Override
// protected Class<?>[] getServletConfigClasses() {
// return new Class<?>[] { ClientWebConfig.class };
// }
//
// @Override
// protected String[] getServletMappings() {
// return new String[] { "/*" };
// }
//
//}
// }