zoukankan      html  css  js  c++  java
  • Spring MVC 流程

    1. 检查是否为上传文件。 

    2. 通过HandlerMapping获取HandlerExecutionChain:

        DispatcherServlet 中包含:handlerMappings ,

        遍历获取正确的:HandlerMapping(RequestMappingHandlerMapping ) ,

        具体的handlerMapping中包含:handlerMap ;

        handlermap中为键值对:path = 对应的controller,例如:/hello/hello.htm=com.mumu.controller.HelloController@85a1ef

        得到请求对应的HandlerExecutionChain,HandlerExecutionChain中包含:

        1). interceptors:

        2). 对应的controller实例 

    3. HandlerAdapter: 

        1). 将com.mumu.controller.HelloController@85a1ef传给获取适配器方法,遍历DispatcherServlet的handlerAdapters ,判断启用的是哪种Adapter,

             继承Controller的还是注解的 

        2). 根据合适的Adater获取ServletHandlerMethodResolver: 

             org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter@156b510 的 methodResolverCache: 

            {class com.mumu.controller.HelloController=org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver@15c2d4e} 

        3). ServletHandlerMethodResolver,在它里面存储了方法和注解的关系 

             org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver@15c2d4e 

             [public java.lang.String com.mumu.controller.HelloController.hello3(javax.servlet.http.HttpServletRequest)=[/hello3.htm], public java.lang.String     

             com.mumu.controller.HelloController.hello2(java.lang.String,org.springframework.ui.Model)=[/hello2.htm], public java.lang.String 

             com.mumu.controller.HelloController.hello(java.lang.String,java.util.Map)=[/hello1.htm], 

              public java.lang.String com.mumu.controller.HelloController.hello(java.lang.String)=[/hello.htm]] 

    4. 将上面信息汇总,反射调用方法,获取返回值 

    5. 返回值交给视图解析器去解析:InternalResourceViewResolver 

  • 相关阅读:
    base64加密后字符串长度
    Mysql如何查字段的长度,Mysql中length()、char_length()的区别
    Java 逆变与协变的名词说明
    Java 泛型在实际开发中的应用
    MySQL自增主键排序问题
    【python基础】怎么实现装饰器?
    【python基础】列表推导式
    【python】爬虫实践项目(一):39问医生
    关于DRF序列化器模型字段参数设置报错AssertionError: May not set both `read_only` and `write_only`
    DRF学习笔记
  • 原文地址:https://www.cnblogs.com/Jtianlin/p/4524676.html
Copyright © 2011-2022 走看看