Cake Mall Case

This cake store is based on MyBatis to display cakes.

Mybatis is a framework, an application skeleton that can be customized by application developers, and a rule that ensures that developers follow the same way to develop programs and encapsulate basic functions. Advantages: 1. Greatly improve the efficiency of development 2. Unified coding rules, conducive to team management 3. Flexible configuration applications, with better maintainability.

This project uses Mybatis annotation development, batch processing, paging processing, and a three-tier architecture based on the MVC model.

In the MVC pattern, an application is divided into three parts: Model, View and Controller. Next, let's get to know these three parts.

Model: Responsible for encapsulating the state of the application and implementing the functions of the application. It is usually divided into data model and business logic model. The data model is used to store business data, such as order information, user information, etc.; and the business logic model contains application business operations, such as order addition or modification.

View: Used to show the content of the model to the user. The user can request the model to update through the view. The view obtains the data to be displayed from the model, and then presents it to the user in its own way, which is equivalent to providing an interface to interact with the user; after the user operates on the interface or fills in, it will click the submit button or trigger other events Way to send a request to the controller.

Controller (Controller): used to control the flow of the application and process the requests issued by the view. When the controller receives the user's request, it will map the user's data with the update of the model, that is, call the model to implement the function requested by the user; then the controller will select the view for the response and update the data after the model Show it to users.

Development environment: win10, database MySQL, tomcat-8.5, development tool IDEA

1. The database design of this cake store is designed into 3 tables: cake information, classification, and account management. Account management: account name, password, etc. Cake information: the name, type, size, taste, sweetness and weight of the cake. Classification: Cake classification birthday, wedding, etc.

Second, create the project entity, dao, biz, controller, global. 1. Entity entity class for its services 2. Dao (interact with the database, perform data management, add, delete, modify, and check), biz, Model models to implement business functions. 3. The view is presented by JSP and interacts with the user. 4. Controller, to realize the controller, to realize the function, the controller calls the model to the view to present it. 5. Global global: coding filter, core controller, Dao factory (tool class for obtaining persistent operation objects, using singleton mode).

Third, the in-depth use of Mybatis 1. Introduce MyBatis dependency 2. Perform core file configuration 3. Create entity class entity 4. Create Mapper mapping file 5. Create test class: initialize SqlSessionFactory, use SqlSession operation

Guess you like

Origin blog.csdn.net/hgfhjtff/article/details/107764453