DispatcherServlet中的URL处理

1.当处理一个URL请求时,将会在DispatcherServlet模块中,循环获取相应的处理Handler。如下图:

2.getHandler的关键函数

protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
        Iterator var2 = this.handlerMappings.iterator();

        HandlerExecutionChain handler;
        do {
            if(!var2.hasNext()) {
                return null;
            }

            HandlerMapping hm = (HandlerMapping)var2.next();
            if(this.logger.isTraceEnabled()) {
                this.logger.trace("Testing handler map [" + hm + "] in DispatcherServlet with name \'" + this.getServletName() + "\'");
            }
            //通过遍历比较,
            handler = hm.getHandler(request);
        } while(handler == null);

        return handler;
    }

3.getHandler中的局部变量