SpringMVC

1.Spring Web MVC

1.1 DispatcherServlet

java configuration 配置 DispatcherServlet

public static MyWebApplicationInitializer implements WebApplicationInitializer{
    @Override
    public void onStartup(ServletContext servletCxt){
        //Load Spring web application configuration
        AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext();
        ac.register(AppConfig.class);
        ac.refresh();

        //Create and register the DispatcherServlet
        DispatcherServlet servlet = new DispatcherServlet(ac);
        ServletRegistration.Dynamic registration = servletCxt.addServlet("app",servlet_;
        registration.setLoadStartup(1);
        registration.addMapping("app/*");
    }
}
上一篇:SpringMVC面试


下一篇:牛批!阿里P8Java架构师写了一份Spring MVC教程,已整理成文档。