@RequestMapping 原理(程序如何找到请求的方法的?)

Spring是怎样检测并处理我们@RequestMapping注解的: 

  1. 扫描所有注册的Bean 
  2. 遍历这些Bean,依次判断是否是处理器,并检测其HandlerMethod 
  3. 遍历Handler中的所有方法,找出其中被@RequestMapping注解标记的方法。 
  4. 获取方法method上的@RequestMapping实例。 
  5. 检查方法所属的类有没有@RequestMapping注解  
  6. 将类层次的RequestMapping和方法级别的RequestMapping结合  (createRequestMappingInfo) 
  7. 当请求到达时,去urlMap中需找匹配的url,以及获取对应mapping实例,然后去handlerMethods中获取匹配HandlerMethod实例。 
  8. 将RequestMappingInfo实例以及处理器方法注册到缓存中。

原文入口:https://blog.csdn.net/u013072477/article/details/80237444

一个小小后端的爬行痕迹
原文地址:https://www.cnblogs.com/heikedeblack/p/14857807.html