01.doDispatch方法中代码如下:
HandlerExecutionChain mappedHandler=this.getHandler(processedRequest) 02.DispatcherServlet类中 找到getHandler()
protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
Iterator var2 = this.handlerMappings.iterator();
HandlerMapping hm = (HandlerMapping)var2.next();
handler = hm.getHandler(request);
} 03.我们转而去找HandlerMapping的getHandler()
却发现HandlerMapping是一个接口,所以我们就去找它的实现类AbstractHandlerMapping
-的getHandler() 如下:
public final HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception{
//将request转换成一个Handler
Object handler = this.getHandlerInternal(request);
return this.getHandlerExecutionChain(handler, request);
} 04. protected HandlerExecutionChain getHandlerExecutionChain(Object handler, HttpServletRequest request) {
HandlerExecutionChain chain = handler instanceof HandlerExecutionChain ? (HandlerExecutionChain)handler : new HandlerExecutionChain(handler);
String lookupPath = this.urlPathHelper.getLookupPathForRequest(request);
Iterator var5 = this.adaptedInterceptors.iterator(); while(var5.hasNext()) {
HandlerInterceptor interceptor = (HandlerInterceptor)var5.next();
if (interceptor instanceof MappedInterceptor) {
MappedInterceptor mappedInterceptor = (MappedInterceptor)interceptor;
if (mappedInterceptor.matches(lookupPath, this.pathMatcher)) {
chain.addInterceptor(mappedInterceptor.getInterceptor());
}
} else {
chain.addInterceptor(interceptor);
}
} return chain;
} 结论:处理器执行链=1个Handler+N个Interceptor

最新文章

  1. 查看mysql语句运行时间的2种方法
  2. TCP状态
  3. jquery颜色选择器
  4. EditText 显示明文和密码
  5. SQL SERVER 将表中字符串转换为数字的函数 (详询请加qq:2085920154)
  6. web中的触摸(touch)与手势(gesture)事件
  7. SourceTree 免登录跳过初始设置
  8. 修改linux系统时间的方法(date命令)
  9. CF 337D Book of Evil 树形DP 好题
  10. C#测量程序运行时间及cpu使用时间
  11. POJ 2431 Expedition (STL 优先权队列)
  12. java IO和NIO的场景选择
  13. scaletype
  14. 倒计时IE6+
  15. json转义字符串
  16. java线程与进程
  17. 【玩转开源】使用 PhoenixSuit 线刷 Android 镜像
  18. error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
  19. python的for循环、while循环
  20. @Autowired Map<String , Object> xx

热门文章

  1. Appium禁止appium setting和unlock在设备上重复安装
  2. hdu4832Chess(dp)
  3. (C#)asp_net调试错误解决方法收集(1)
  4. hdu6376 度度熊剪纸条
  5. webpack入门之最简单的例子 webpack4
  6. Cuda入门笔记
  7. Java生成-zipf分布的数据集(自定义倾斜度,用作spark data skew测试)
  8. PostgreSQL 的日期函数用法举例
  9. POJ 3133 Manhattan Wiring (插头DP,轮廓线,经典)
  10. 100行代码让您学会JavaScript原生的Proxy设计模式