美文网首页
SpringMvc源码解析

SpringMvc源码解析

作者: 一曲三月 | 来源:发表于2021-11-21 16:57 被阅读0次

    1,package org.springframework.web.servlet;
    前端控制器: public class DispatcherServlet extends FrameworkServlet
    方法: doDispatch(HttpServletRequest request, HttpServletResponse response)
    // Determine handler for the current request. 获取处理器
    mappedHandler = getHandler(processedRequest);
    // 获取处理器
    protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
    for (HandlerMapping hm : this.handlerMappings) {//查找处理器映射器
    if (logger.isTraceEnabled()) {
    logger.trace(
    "Testing handler map [" + hm + "] in DispatcherServlet with name '" + getServletName() + "'");
    }
    HandlerExecutionChain handler = hm.getHandler(request); //获取处理器
    if (handler != null) {
    return handler;
    }
    }
    return null;
    }

                // Determine handler adapter for the current request. 获取处理器适配器
        HandlerAdapter ha = getHandlerAdapter(mappedHandler.getHandler());
              // Actually invoke the handler. 执行处理器
         mv = ha.handle(processedRequest, response, mappedHandler.getHandler());
            applyDefaultViewName(request, mv);  返回mv
        mappedHandler.applyPostHandle(processedRequest, response, mv);

    相关文章

      网友评论

          本文标题:SpringMvc源码解析

          本文链接:https://www.haomeiwen.com/subject/hwcmtrtx.html