一.原理步骤:
1.由客户端发送请求到DispatcherServlet。
2.由DispatcherServlet控制器查询一个或多个HandlerMapping,找到处理请求的Controller。
3.DispatcherServlet将请求提交到Controller。
4.Controller调用业务逻辑处理后,返回ModelAndView。
5.Dispatcher调用一个或多个ViewResoler视图解析器,找到ModelAndView指定的视图。
6.视图负责将结果显示到客户端。
二.图解:
三.使用步骤:
1.添加依赖:
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.2.6.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-core --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-