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方法真正調(diào)用的其實(shí)就是RequestMappingHandlerMapping.getHadler方法,返回的HandlerExecutionChain中有真正的handler和3個攔截器,分別是LongTaskTimingHandlerInterceptor
,ConversionServiceExposingInterceptor
,ResourceUrlProviderExposingInterceptor
。
- RequestMappingHandlerMapping是怎么通過request定位到對應(yīng)的handler的
- RequestMappingHandlerMapping怎么獲取到攔截器的,如果我要寫個攔截器,應(yīng)該怎么配置,有什么注意事項(xiàng)
//todo