您的位置:首页 > 移动开发

读Spring的源代码六:Controller mapping的注册过程

2015-07-28 11:26 218 查看
DispatchServlet每次收到请求后,都会去一个LinkedHashMap(handlerMethods)里面找对应的handler。这个map的初始化过程在下图你可以找到。 这个map是放在AbstractHandlerMethodMapping中的。



注:观察下面方法你会发现spring会根据时候含有注释Controller或RequestMapping来判断是否是handler。

protected boolean isHandler(Class<?> beanType) {
return ((AnnotationUtils.findAnnotation(beanType, Controller.class) != null) ||
(AnnotationUtils.findAnnotation(beanType, RequestMapping.class) != null));
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: