美文网首页
源码跟踪-springmvc(三):RequestMapping

源码跟踪-springmvc(三):RequestMapping

作者: A_19cb | 来源:发表于2018-12-23 18:32 被阅读0次

    DispatcherServlet.getHandler

    protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
            if (this.handlerMappings != null) {
                for (HandlerMapping mapping : this.handlerMappings) {
                    HandlerExecutionChain handler = mapping.getHandler(request);
                    if (handler != null) {
                        return handler;
                    }
                }
            }
            return null;
        }
    

    DispatcherServlet.getHandler方法真正调用的其实就是RequestMappingHandlerMapping.getHadler方法,返回的HandlerExecutionChain中有真正的handler和3个拦截器,分别是LongTaskTimingHandlerInterceptorConversionServiceExposingInterceptorResourceUrlProviderExposingInterceptor

    1. RequestMappingHandlerMapping是怎么通过request定位到对应的handler的
    2. RequestMappingHandlerMapping怎么获取到拦截器的,如果我要写个拦截器,应该怎么配置,有什么注意事项

    //todo

    相关文章

      网友评论

          本文标题:源码跟踪-springmvc(三):RequestMapping

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