SpringMvc源码解析

2021-11-21  本文已影响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);
上一篇下一篇

猜你喜欢

热点阅读