# SpringMVC執行原理 ###### tags: `SpringMVC-基礎` 紅色部分是設計者需要編寫的部分,其餘都由SpringMVC完成  ### 簡要分析執行流程 1.DispatcherServlet表示前置控制器,是整個SpringMVC的控制中心。用戶發出請求,DispatcherServlet接收請求並攔截請求 * 我們假設請求的url為:http://localhost:8080/SpringMVC/hello * 如上url拆分成三部分: * http://localhost:8080 服務器域名 * SpringMVC部屬在服務器上的web站點 * hello表示控制器 * 通過分析,如上url表示為:請求位於服務器localhost:8080上的SpringMVC站點的hello控制器  2.HandlerMapping為處理器映射,DispatcherServlet調用HandlerMapping,HandlerMapping根據請求url查找Handler  3.HandlerExcution表示具體的Handler,其主要作用是根據url查找控制器,如上url被查找控制器為:hello 4.HandlerExcution將解析後的信息傳遞給DispatcherServlet,如解析控制器映射等。 5.HandlerAdapter表示處理器適配器,其按照特定的規則去執行Handler。  6.Handler讓具體的Controller執行。 7.Controller將具體的執行信息返回給HandlerAdapter,如ModelAndView。 8.HandlerAdapter將視圖邏輯名或模型傳遞給DispatcherServlet。 9.DispatcherServlet調用視圖解析器(ViewResolver)來解析HandlerAdaptert傳遞的邏輯視圖名。 10.視圖解析器將解析的邏輯視圖名傳給DispatcherServlet。  11.DispatcherServlet根據試圖解析器解析的視圖結果,調用具體的視圖。 12.最終視圖呈現給用戶。 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up