Good learning Java programmers to share MVC route overview of SpringMVC

  Good programmers Java learning routes Share SpringMVC the MVC summary Introduction: the current Web development is the mainstream model MVC , the Spring provides SpringMVC module, support for MVC model development, this chapter we will MVC model a whole recognize.

Web evolution development model

  In the early java web development, we will display the page, business logic, data manipulation put all JSP or JavaBean to achieve, that is Model1


  The disadvantage of this model is:

  1, high coupling, all codes are mixed together in the JSP, Java and HTML, difficult to prepare

  2, is not conducive to the division of labor, Java developers have completed the front pages and Java application development

  3, difficult to test, the front pages and Java interdependent and can not run alone, alone test

  Code reuse is difficult

  With the development of the times, and later appeared Servlet + JSP + JavaBean development model, which is Model2


  Model2 i.e. early MVC, where the display page, the request processing, separately from the data operation code, addresses the problem of high Model1 coupling.

  User requests previously submitted to the Servlet, Servlet JavaBean then call for database operations, and then bind the data to the JSP, JSP will be returned to the user.

MVC terminology

  Model M is representative of the model layer, is responsible for processing service logic and data, such as: CRUD database.

  V represents the view is the View layer, responsible for interactive display and user data, such as: JSP pages.

  Controller C is representative of a controller layer, responsible for interaction between the controller and the model view, the user's request to the appropriate distribution model, and the model change promptly reflected in the view.

MVC development

  To solve the problem of database transaction processing, JavaBean is divided into three parts:

  Data bean physical layer, encapsulating the table

  dao data access layer is responsible for each table change search deletions

  service business logic layer, is responsible for implementing affairs


MVC benefits

  1. low coupling

  View and business logic layer separated, and we can modify the page style and individually java logic code, without considering other portions of the code will affect.

  2. The high reusability

  After the separation of service logic and views, different JSP pages can reuse the same business logic code, such as mobile phones and computers order page order page, although different page content, the same business logic order. The same JSP page can use a different business logic, such as ordering processes changed, but did not modify the page style, we only need to modify the business logic behind without the need to modify the page.

  3. fast deployment, low life-cycle costs

  MVC development and maintenance of the technical content of the user interface is reduced. Use MVC model development time to get considerably reduced, which enables programmers (Java developer) to focus on business logic, interface programmers (HTML and JSP developers) to concentrate on the form of expression.

  4. High maintainability

  And business logic layer separating the view makes WEB application easier to maintain and modify.

 

  Of course, MVC has its drawbacks:

  1, the structure is complicated, not suitable for small and medium sized applications.

  2, each layer calls to each other, the relationship between complex, difficult to debug.

  3, inefficient

to sum up

  The main role of MVC is decoupled, after reducing coupling, project maintenance, testing, code reuse becomes easier to understand the MVC pattern, we will learn SpringMVC framework.

Guess you like

Origin www.cnblogs.com/gcghcxy/p/11288653.html