1: The user initiates a request, which will be intercepted by the front-end controller (dispatcher servlet)
2: The front-end controller (dispatcher servlet) requests the Handler mapping to find the Handler
3: The Handler mapping finds the corresponding Handler (which can be more annotated or XML configured) according to the configuration. It may contain multiple Interceptor interceptors and return them to the front-end controller
4: The front-end controller (dispatcher servlet) requests the Handler adapter to execute the corresponding Handler
5: The adapter is executed by the corresponding Handler processor
6: After the Handler processor completes execution, it returns the ModelAndView object to the processor adapter
7: The processor adapter accepts the result returned by the Handler processor and returns the result to the front-end controller (dispatcher servlet)
8: The front-end controller (dispatcher servlet) receives the data and view information returned by the processor adapter, requests the view parser to parse the corresponding view
9: The View parser returns the corresponding View results matched according to the View information to the front-end controller
10: The front-end controller receives the specific View, renders the View, fills the Model data into the View view, and generates the final View
11: The front-end controller returns the result to the user
Build demo from scratch
Create project:
Create a new dynamic Web project under Eclipse
Project default directory structure:
Add jar package dependency
Import the corresponding jar package under webcontent > WEB-INF > lib folder. The core jar package is spring-webmvc-5.0.0.RELEASE.jar. The others are mainly spring package for managing context and beande, jstl tag library and a log package for printing logs:
Configuring the front-end controller in web.xml
The front-end controller is equivalent to the proprietary servlet of Spring MVC, which is used to intercept all qualified requests and submit them to the framework for subsequent processing
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi\="http://www.w3.org/2001/XMLSchema-instance" xmlns\="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation\="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app\_3\_1.xsd" id\="WebApp\_ID" version\="3.1"\> <!-- Configure front-end controller-DispatchServlet \--> <servlet\> <servlet-name\>springMvcNext</servlet-name\> <servlet-class\>org.springframework.web.servlet.DispatcherServlet</servlet-class\> <!-- contextConfigLocation Not required if not configured contextConfigLocation, springmvc The default configuration file is: WEB-INF/servlet of name+"-servlet.xml" \--> <init-param\> <param-name\>contextConfigLocation</param-name\> <param-value\>classpath:applicationContext.xml</param-value\> </init-param\> </servlet\> <servlet-mapping\> <servlet-name\>springMvcNext</servlet-name\> <url-pattern\>/</url-pattern\> <!--according to url-pattern The set rules intercept requests from users. All requests, including static resources, are intercepted here -> </servlet-mapping\> </web-app\>
The url matching rule defined in the tag is in the form of *. action, the corresponding servlet name is springMvcNext, and the configured controller is org.springframework.web.servlet.DispatchServlet. The controller is the front-end controller of the current spring MVC project, and the tag is the parameter dependent on the current controller. The two parameters represent the context parameter and parameter loading path respectively.
About classpath: represents the compiled output path of the web project
Configure spring MVC configuration
Add the applicationContext.xml file in the java source code directory
Specific contents:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns\="http://www.springframework.org/schema/beans" xmlns:xsi\="http://www.w3.org/2001/XMLSchema-instance" xmlns:p\="http://www.springframework.org/schema/p" xmlns:context\="http://www.springframework.org/schema/context" xmlns:mvc\="http://www.springframework.org/schema/mvc" xsi:schemaLocation\="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"\> <!-- The package scanner tag will be used for activation Spring MVC Annotation scanning function, allowing the use of@Controller and@RequestMapping Etc.\--> <context:component-scan base-package\="com.sl.controller" /> <!-- Annotation driven \--> <mvc:annotation-driven /> <!-- Configure view parser \--> <bean class\="org.springframework.web.servlet.view.InternalResourceViewResolver" id\="internalResourceViewResolver"\> <property name\="prefix" value\="/WEB-INF/view/" /> <property name\="suffix" value\=".jsp" /> </bean\> </beans\>
Add Controller and View
Kafka advanced knowledge points
Kafka advanced knowledge points
The 44 Kafka knowledge points (Basic + Advanced + Advanced) are analyzed as follows
Due to the limited space, the editor has compiled the above * * Kafka source code analysis and practice, Kafka interview topic analysis, review and learning necessary 44 Kafka knowledge points (Basic + Advanced + Advanced) into a volume, all of which are PDF documents**
1630840246844)]
Kafka advanced knowledge points
[external chain picture transferring... (img-O8iZb684-1630840246845)]
The 44 Kafka knowledge points (Basic + Advanced + Advanced) are analyzed as follows
[external chain picture transferring... (img-hxKtrsBN-1630840246845)]
Due to the limited space, the editor has compiled the above * * Kafka source code analysis and practice, Kafka interview topic analysis, review and learning necessary 44 Kafka knowledge points (Basic + Advanced + Advanced) into a volume, all of which are PDF documents**