web.xml加载DispatcherServlet(子类兼有自己特性还有父类所有的特性,若有覆盖方法的用子类自己的,父类的某个方法有入口作用
那么如果用子类的话(子类 覆盖了这个方法)子类的这个方法也就有了入口特性)
源配入口
DispatcherServlet--》应用上下文初始化--》执行转发--》通过各种拦截器--》最终跳转
FrameworkServlet
public void onApplicationEvent(ContextRefreshedEvent event)
{
this.refreshEventReceived = true;
onRefresh(event.getApplicationContext());
}
protected void onRefresh(ApplicationContext context) {}///框架在写接口时会自己先写一个抽象的供自己调用,后面有子类继承他的时候覆写这个方法就会在子类中
调用这个具体方法了
DispatcherServlet
protected void onRefresh(ApplicationContext context)
{
initStrategies(context);
}
protected void initStrategies(ApplicationContext context)
{
initMultipartResolver(context);
initLocaleResolver(context);
initThemeResolver(context);
initHandlerMappings(context);
initHandlerAdapters(context);
initHandlerExceptionResolvers(context);
initRequestToViewNameTranslator(context);
initViewResolvers(context);
initFlashMapManager(context);
}
protected void doService(HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doDispatch(request, response);
}
protected void doDispatch(HttpServletRequest request, HttpServletResponse response)
throws Exception
{
mappedHandler.applyPostHandle(processedRequest, response, mv);
processDispatchResult(processedRequest, response, mappedHandler, mv, dispatchException);
}
private void processDispatchResult(HttpServletRequest request, HttpServletResponse response, HandlerExecutionChain mappedHandler, ModelAndView mv, Exception exception)
throws Exception
{
boolean errorView = false;
if (exception != null) {
if ((exception instanceof ModelAndViewDefiningException))
{
this.logger.debug("ModelAndViewDefiningException encountered", exception);
mv = ((ModelAndViewDefiningException)exception).getModelAndView();
}
else
{
Object handler = mappedHandler != null ? mappedHandler.getHandler() : null;
mv = processHandlerException(request, response, handler, exception);
errorView = mv != null;
}
}
if ((mv != null) && (!mv.wasCleared()))
{
render(mv, request, response);
if (errorView) {
WebUtils.clearErrorRequestAttributes(request);
}
}
else if (this.logger.isDebugEnabled())
{
this.logger.debug("Null ModelAndView returned to DispatcherServlet with name '" + getServletName() + "': assuming HandlerAdapter completed request handling");
}
if (WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted()) {
return;
}
if (mappedHandler != null) {
mappedHandler.triggerAfterCompletion(request, response, null);
}
}