本文主要是介绍流程图解Spring Framework(十) Spring MVC如何根据请求匹配处理的?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Tomcat入口处理
各个组件的作用
- Server: In the Tomcat world, a Server represents the whole container.
- Service: A Service is an intermediate component which lives inside a Server and ties one or more Connectors to exactly one Engine.
- Engine: An Engine represents request processing pipeline for a specific Service.
- Host: A Host is an association of a network name, e.g. www.yourcompany.com, to the Tomcat server.
- Context: A Context represents a web application. A Host may contain multiple contexts, each with a unique path.
处理流程
- Tomcat server启动
- 首先客户端的请求会被service的connector解析为request/response,传递给Engine处理
- 然后Engine(StandardEngine ----> StandardEngineValve#invoke —> hostPipeline#invoke)
- 然后call给Host(StandardHost —> StandardHostValue#invoke —> contextPipeline#invoke)
- 然后call给Context(StandardContext —> StandardContextValue#invoke)
- 然后call给Wrapper(StandardWrapper—> StandardWrapperValue#invoke —> ApplicationFilterChain#doFilter -> Servlet#service)
任何一个组件都包含了pipeline。基础依赖 Container
SpringMVC
SpringMVC 就是实现了Servlet,即DispatcherServlet
参数解析并赋值
org.springframework.web.bind.annotation.support.HandlerMethodInvoker#resolveHandlerArguments
执行方法调用
org.springframework.core.BridgeMethodResolver#findBridgedMethod
绘制视图
org.springframework.web.servlet.DispatcherServlet#processDispatchResult
扩展点
- HandlerInterceptor 自定义拦截器
这篇关于流程图解Spring Framework(十) Spring MVC如何根据请求匹配处理的?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!