πβ¨MVC development rules in detail
This is the third day of my participation in the August Text Challenge.More challenges in August.
π¨π author: Java Academic Conference
π¦ Storage: Github, Gitee
βοΈ blogs: CSDN, Nuggets, InfoQ, Cloud + Community
π public account: Java Academic Party
π« special statement: the original is not easy, shall not be reproduced or copied without authorization, if you need to reproduce can contact xiaobian authorization.
π Copyright notice: part of the text or pictures in the article come from the Internet and Baidu Encyclopedia, if there is infringement, please contact xiaobian as soon as possible. Wechat search public Java academic party contact xiaobian.
β οΈ The winner of life never loses courage in the face of setbacks.
π Hello! Today, I am your old friend Java academic lie prone to continue to share the MVC framework, MVC is a place at the table in the program, M refers to the business model, V is refers to the user interface, C is the controller, using the MVC will M and V is the purpose of the implementation of the code, so that the same program can use different forms. For example, a batch of statistical data can be represented by bar charts and pie charts respectively. The purpose of C is to ensure the synchronization of M and V. Once M changes, V should be updated synchronously. Next, I will introduce the MCV development rules in detail.
1. Introduction to MVC framework
- The MVC development rules specify which roles must be present in the development of Internet communications
- The MVC development rules specify that roles and responsibilities must arise in the development of Internet communications
- MVC development rules specify the order in which roles must appear during the development of Internet communications
2. The role
-
DOA object: The DOA object provides the operation details of a table file, reducing the operation difficulty of table files.
Avoid repeatedly open file operation code, improve code reuse.
-
Service object: a Service object that provides a specific solution for a Service.
A method of the Service object specifies the solution of a business
Avoid repetitive business development and provide reusability.
Each business on the site has a separate standard solution.
3. The business
- The browser sends a request to the Http server
- The user sends a request to the site
4. Service characteristics
- In a real business scenario, a business contains multiple branch tasks. So solving business development is often a huge effort.
- In real service scenarios, the current service can be successfully processed only when all branch tasks are successfully solved
5. Solve business development problems
-
A business can be repeated in multiple places on the site, and without encapsulation, it becomes more difficult to develop,
Repeat business solution code development.
-
When different programmers face the same business, they often offer different solutions.
The data resulting in the final solution will be biased.
6.MVC development rule — the role that must appear in the development of Internet communication
There are three roles that must appear in an Internet development process:
- C Controller Object: Servlet object
- M Model Object: Service model object
- V View Object: View layer object (JSP or HttpServletResponse)
7.MVC Development rules — The responsibilities of the roles that must appear in the development of Internet communications
- C (Servlet object) :
- [can] call [request object] read [request packet] parameter information (can means can not call)
- The Servlet object must be called to process the business
- Call the View-layer object to write the result to the response body
- M (Service object) :
- Handle all branch tasks in the business
- Check whether the branch service is successfully processed
- The result must be returned to the control layer object via a return.
- V (jsp/HttpServletResponse ):
- [Forbidden to participate in business processing]
- The unique task writes the result of the processing to the response body
8.MVC development rule — The sequence of roles that must appear in the development of Internet communication
8.1 Request Invocation Sequence
When the browser makes a request to the server it must hand it to the control layer object (Servlet object)
The Servlet does not process the business and calls the Service object.
The service object has the right to call the DOA object to add, delete, modify and query the table file
8.2 Response Sequence
After the branch task is completed, all the branch tasks are handed to the Service object. The Service object can only give the result to the Servlet object.
The Servlet object then gives the result to the View object, which writes the result to the response body for output
The black arrow represents the call and the red arrow represents the response
Today first share here, tomorrow to continue to share with you, pay attention not to get lost yo, we will see π tomorrow.
Above project source code,Get it for free at planet πplanet(making address)If I didn’t have my Github buddies. You can search π wechat official account:Java academic lie proneπ send MVC, free to send you the project source address, the source code is tested by the small editor π§, absolutely reliable, free to use.
——–π after watching the big guys can pay attention to the xiaobian, will always update the small skills, free to share with you!! π — — — — — — — — —
Click π planet for quick access to the Github planet!! Inside there are more fun technology, waiting for you to explore yo πͺ!!