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个拦截器,分别是LongTaskTimingHandlerInterceptor
,ConversionServiceExposingInterceptor
,ResourceUrlProviderExposingInterceptor
。
- RequestMappingHandlerMapping是怎么通过request定位到对应的handler的
- RequestMappingHandlerMapping怎么获取到拦截器的,如果我要写个拦截器,应该怎么配置,有什么注意事项
//todo
网友评论