Use the springboot framework as a web project to implement simple addition, deletion, modification, and query functions. springbootweb

Source: Internet
Author: User

Use the springboot framework as a web project to implement simple addition, deletion, modification, and query functions. springbootweb

The main process of completing this project is as follows:

1. First of all, we need to understand the requirements so that we can design the details well and make things better meet the requirements.

2. Create an entity class as needed, such as the student management system. Should we create an entity class for the student?

Student information, such as name, age, gender, ID card number, class, and phone number. Set all of them as attributes of students.

3. Create a student table in the database based on the student attributes and set the attributes of each student to a field in the student table.

The names of entity classes are consistent, which avoids unnecessary troubles. Second, their types must be consistent. For example, if the student name is a string and the age is an integer,

In addition, we should give them a reasonable length in the database based on different attributes, not too large. This saves storage space.

4. Write the persistence layer according to specific functional requirements. We usually design the persistence layer method as an excuse, so that we can directly write SQL statements in an xml file.

We should pay attention to some configurations to ensure that the xml file can be scanned. In this way, the SQL statement in the xml file can be executed.

When writing an SQL statement, you must note that the id must be consistent with the method name of the persistent layer, in this way, the specified SQL statement can be executed only when the method of the persistent layer is called.

. In addition, we should also pay attention to the return values and parameter values of the methods to be consistent with those in SQL. Usually we should test every method well, so that we can have problems at any time.

Solution.

5. The service layer is similar to the above. We also use the service as an excuse to write, which can reduce the code coupling and then write the implementation class for the service, we usually call the above persistent layer.

In service, there are usually a lot of business logic. We should fulfill the corresponding business requirements according to specific requirements. Here, we must think too much about the logic, so that the logic should not be made from the vulnerability.

6. The controller layer is mainly used to handle frontend interaction. Many request paths and request types are designed here. What formats are used for data interaction between the frontend and backend?

We usually use json. In springboot, the default format is json for data interaction.

7. The front-end is the Code. On the front-end page, we perform a series of operations, such as adding, deleting, modifying, and querying the code. We click the corresponding button to add students, you can use

Js Code allows him to transmit the corresponding data and operations to the corresponding controller through the request path so that the controller can further process the corresponding requests. Of course, the controller will call the service layer and the service will call

Persistent layer, so that the database can perform the corresponding operations at the end, and finally the corresponding results are returned to the upload layer by layer, so that the desired results can be displayed on the front-end page.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.