SpringMVC

让人想犯罪 __ 提交于 2020-03-29 11:38:00

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/*");
    }
}

1.1.1 Context Hierachy

1.1.2 Special Bean Types

  • HandlerMapping : 主要实现 RequestMappingHandlerMapping 和SimpleUrlHandlerMapping
  • HandlerAdapter :
  • HandlerExceptionResolver: 异常策略
  • ViewResolver: 视图解析
  • LocaleResolver,LocaleContextResolver: 本地化策略
  • ThemeResolver: 个性化策略
  • MultipartResover: 多内容解析
  • FlashMapManager:存储和传递请求,用来重定向
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!