1. The MVC concept
1.1 Front-end controller
1.2 MVC Concept The core idea of MVC---separation of business data extraction and business data presentation
View: The views layer, provides UI for the user, focuses on the presentation of the data; Model: The modeling layer, the information representation of the business data, the focus on supporting the information structure of the business, usually the combination of multiple business entities; Cotroller: Control layer, invoking business logic to produce the appropriate data, Passing data to the view layer for rendering;
What is MVC?
1, MVC is an architectural model, is the process of Division, Division of Labor, both independent and cooperative work.
2, MVC is a way of thinking, the model layer of thinking for the user to show what, in the view layer to think about how to layout, in the control layer thinking calls those business logic.
2. Spring MVC concept
2.1 Spring MVC Basic Concepts
1, Dispatcherservlet: Front Controller 2, controllers: Call the business logic to generate the model of the place 3, handleradapter:d Ispatcherservlet through Handleradapter call Controller4, Handlerinterceptor: Interceptor This interface provides after Posthandle Prehandle three methods, Call controller before and after using 5, handlermapping: The front controller and controller mapping relationship Class 6, Handlerexecutionchain:prehandle->controller method- >posthandle->aftercompletion execution chain 7, Modelandview:model specific performance 8, Viewresolver: View parser, decide which view to use to render the view.
2.2 Schema Flowchart
2.3 Architectural Processes
1, the user sends the request to the front controller Dispatcherservlet
2 . Dispatcherservlet received a request to call the Handlermapping processor mapper.
3 . The processor mapper locates the specific processor according to the request URL, and returns the Processor object and the processor interceptor (if any) to Dispatcherservlet.
4. Dispatcherservlet calls the processor via the Handleradapter processor adapter
5, the execution Processor (Controller, also known as the back-end controller).
6, controller execution completed return Modelandview
7, handleradapter the controller execution results Modelandview returned to Dispatcherservlet
8. Dispatcherservlet Pass Modelandview to Viewreslover view parser
9, Viewreslover after parsing return to the specific view
10. Dispatcherservlet View (to populate the model data into the view)
11. Dispatcherservlet Response User
3. Apply Maven tools to manage Springmvc
3.1 maven's three key concepts : Configuration Pom.xml, dependency dependency, coordinate coordinates (groupid,artifactid,version,packaging)
3.2 maven ConfigurationSetting.xml Configuring a mirrored warehouse: using a mirrored warehouse in UK to improve access success
Mirroring configuration, each time access to MAVEN access to the configuration of the library, download the required packages, so as to reduce the load of the central warehouse, central warehouse in order to avoid a large number of access caused by the service problem sometimes refused
Our visit.
3.3 Maven to create a project
3.3.1. Add maven in Eclipse that inherits Maven, Windows--->prefrences---->maven--->installation---> Add the newly downloaded Maven file, making sure that the path to the profile in user setings is the configuration file that was previously configured with Mirror Setting.xml
3.3.2. To run a command line create a project Note: You need to enter the path of the specified creation project on the command line for example: CD C:\Users\Workspaces\Eclipse
Command: MVN archetype:generate-dgroupid=imooc-arthur-dartifactid=spring-mvc-study-darchetypeartifactid= Maven-archetype-webapp
Parameter explanation: Archetype:generate Call Plugin
GroupId: Coordinates
Artifactid: An element of the coordinates, the root directory name of the directory structure
Archetypeartifactid: A type of directory type, this is the type of WebApp
3.3.3 Building the Spring MVC infrastructure
1. Import Project Import-->maven (Existingmaven Projects)-The file directory you just created Spring-mvc-study
2. When the Java directory is missing, manually add the Java directory right-click Main-->folder-->java
3.pom.xml adding various dependency packages
4.web.xml file Configuration Dispatcherservlet--The core of Spring MVC
5.mvc-dispatcher-servlet.xml enables spring annotation-based di configuration Dispatcherservlet context, only manages beans of type @controller, ignores other types of beans, As @service expands the annotation driver, you can bind the request parameters to the controller parameter configuration viewresolver; You can use multiple viewresolver, sort by the order attribute, internalresourceviewresolver in the end.
6. Create a Controller class
7. Create home.jsp
8. Run Jetty, Access
4. Implementation of SPRINGMVC in specific projects
Spring MVC starts