Spring MVC 架构

整体结构 servlet Httpservlet -- java FrameworkServlet DispatcherServlet --初始化九大组件 doDispatcher -- mappedHandler = getHandler(processedRequest, false); HandlerAdapter ha = getHandlerAdapter(mappedHandler.getHandler()); if (!mappedHandler.applyPreHandle(processedRequest, response)) { return; } // Actually invoke the handler. mv = ha.handle(processedRequest, response, mappedHandler.getHandler()); mappedHandler.applyPostHandle(processedRequest, response, mv); processDispatchResult(processedRequest, response, mappedHandler, mv, dispatchException); [Read More]

Spring MVC-HandlerMapping

HandlerMapping 继承关系 **HandlerMapping** 只有一个方法:通过request获取handler HandlerExecutionChain getHandler(HttpServletRequest request) AbstractHandlerMapping----HandlerMapping的抽象实现 --getHandler方法实现 通过getHandlerInternal获取handler,该方法是子类实现的 具体不同的子类实现方法不一样。 若没有获取到则使用默认的handler handler转String,来获取bean AbstractHandlerMapping –AbstractUrlHandlerMapping –AbstractHanlderMethodMapping [Read More]