I. Introduction to MVC
The full name of MVC is the model View Controller, which is the abbreviation for the models-view-controller, a software design paradigm that organizes the code with a method of business logic, data, and interface display separation. Aggregating business logic into a single component does not require rewriting business logic while improving and personalizing the interface and user interaction.
model is the part of your application that handles application data logic.
Typically, model objects are responsible for accessing data in the database.
View is the part of the application that handles the display of data.
Typically views are created from model data.
A controller is a part of an application that handles user interaction.
Usually the controller is responsible for reading data from the view, controlling user input, and sending data to the model.
Ii. major components of the Java Web application
1.Servlet component--it runs in the Web container, can be dynamically loaded by the Web container, receives browser requests, calls other components to process the request, and returns the processing results. When a browser accesses a servlet, the Web container creates a ServletRequest object and a Servletresponse object, and encapsulates the user's request information in the ServletRequest object. The two objects are then transferred as parameters to the specific method of the servlet. In this method, the request is processed, the processing result is encapsulated in the Servletresponse object, and returned to the Web container. Finally, the Web container returns the results to the browser to parse and display.
2.JSP Component--jsp is a Dynamic Web page technology. It adds the HTML page to the Java script, and the JSP tag forms the JSP file. When a browser requests a JSP page, Tomcat translates the JSP page into a Java file. It then compiles it into a class file, executes it, and returns the resulting HTML page to the client display.
3.JavaBean component-A Java object that conforms to a specific specification. A series of properties are defined in the JavaBean component, and each property provides a setter and getter method so that you can use the component to store some intermediate data. For example, ServletRequest request information, information from the database, and so on.
The 4.EJB component--enterprise java Bean (EJB) component is a server-side Java component. This component is based on the standard distributed object technology, CORBA and RMI technologies, which are used to implement the amount of business logic for enterprise-level applications.
5.XML language-is a markup language used to create custom tags.
6. Web server and Application server--used to process HTTP requests and return HTTP data. It is mainly used to interact with the browser to provide services to the user. The application server can be called by the Web server to handle the business logic. The data it returns is organized into HTML format by the Web server and then returned to the browser to parse.
Third, Java Web solutions (development method)
Jsp+javabean Development Mode -this mode separates the business logic from the page performance, and increases the debugging and maintainability of the program to some extent. Simple, suitable for quick construction and operation of small projects.
The jsp+servlet+javabean development mode --jsp as a view to represent the page, the Servlet acts as a controller, the process of controlling the program and invokes the business, JavaBean encapsulates the business logic. Followed the MVC design pattern.
Struts Development Scenario --A mature MVC development framework. For some large projects, the struts framework improves development efficiency and is of great benefit to later maintenance.
The Spring Development Solution , which is based on two advanced technologies of IOC and AOP, simplifies the complexity of enterprise-level development and is an ideal Web application framework.
struts+hibernate Development -A development scenario that leverages the MVC design pattern of Struts with Hibernate persistence objects.
struts+spring+hibernate Development Program --struts is responsible for the presentation layer, Spring is responsible for the logic layer of the business, Hibernate persistence layer database operations, composed of development scenarios.
Iv. Common Java Web MVC framework
Struts--struts has a set of mutually collaborative classes (components), Servlets, and JSP tag lib. Struts also includes a rich tag library and utility classes that work independently of the framework. Struts has its own controller, and incorporates other technologies to implement the model and view layers (views). At the model level, struts can be easily combined with data access technologies, including EJB,JDBC and Objectrelation Bridge. In the view layer, struts can be combined with these presentation layer components such as jsp,velocity templates,xsl and so on.
Spring--spring is an open source framework that is created to address the complexities of enterprise application development. Spring makes it possible to use basic javabeans to accomplish things that were previously only possible by EJBS. However, the use of spring is not limited to server-side development. From the standpoint of simplicity, testability, and loose coupling, any Java application can benefit from spring.
The Zf--zend framework is a fully PHP5-based, open-source PHP development Framework supported by Zend, which can be used to develop WEB programs and services, and ZF uses MVC (Model–view-controller) Schema mode to detach different parts of the application to facilitate program development and maintenance.
. net--. NET is Microsoft's next-generation technology platform, to build an interconnected application system for agile commerce, which is based on standards, connectivity, adaptation, stability and performance. From a technical point of view, a. NET application is an application that runs on top of the. NET Framework.
The implementation of MVC in Java Web applications