Spring MVC 解析之 DispatcherServlet之handlerMapping和handlerAdapter

1.HandlerMapping
介绍:
Spring mvc 使用HandlerMapping来找到并保存url请求和处理函数间的mapping关系。

举例:
DefaultAnnotationHandlerMapping:将扫描当前所有已经注册的spring beans中的@requestmapping标注以找出url 和 handler method处理函数的关系并予以关联。

2.Handleradapter
介绍:
Spring MVC 通过HandlerAdapter来实际调用处理函数。

举例:
AnnotationMethodHandlerAdapter:DispatcherServlet中根据handlermapping找到对应的handler method后,首先检查当前工程中注册的所有可用的handlerAdapter,根据handlerAdapter中的supports方法找到可以使用的handlerAdapter。通过调用handlerAdapter中的handle方法来处理及准备handler method中的参数及annotation(这就是spring mvc如何将reqeust中的参数变成handle method中的输入参数的地方),最终调用实际的handle method。


本文来自 不设限 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/sjjsh2/article/details/53056712

猜你喜欢

转载自blog.csdn.net/weixin_42868638/article/details/82960779