Send a foundation, ssm, springmvc add, delete, modify and check to familiarize yourself with the project process

If beginners do ssm addition, deletion, modification and inspection process, or are familiar with ssm projects, they often do not know the head and tail, and look at the code randomly

1. Core Principles

1. It is used to send a request to the server
2. The request is intercepted by DispatchServlet
3. DispatchServlet checks whether the url has a corresponding Controller through HandleMapping, and if so, calls the Controller
4. The Controller starts to execute business logic
5. After the Controller is executed, if it returns the character string, then ViewResolver converts the string into the corresponding view object;
if the ModelAndView object is returned, the object itself contains the view object information.
6. DispatchServlet outputs the data in the view object to the server.

7. The server outputs the data to the client.

Some people can't understand the core principle. Next, I will send a picture and go through the simple process.


1. Jsp sends a request The request address on the page, that is, the method address, can also be called calling the background interface, which is the beginning of the whole process

If you don't know the absolute path, go to Baidu.


2. After submitting the url address of the action sent in the first step, the request is intercepted by DispatchServlet, which is configured in web.xml, and the integration ssm meeting must be written


3. At this time, HandleMapping will be used to check whether the url has a corresponding Controller. If there is, the Controller will be called.

This is the configuration file written in springmvc.xml, base-package is the package path of your method address, that is, the jsp send url According to this package, you can quickly find the method you want to call. Steps 2 and 3 are generally built when you build the framework, you only need to modify the package path of the third step.


4. At this time, you have to look at the method, which is the interface called by jsp, also called controller, which receives the things on the page, and then calls the business logic to return the data or result to the page.


After receiving the form and other information, you can call the service interface, which is where the business logic of the method is written.

interface



To implement the interface, here is to call the data layer, which can logically process the data. I just simply save it here, no logic, and return directly



Data layer interface: Configure the automatic reflection mechanism of mybatis to find the sql under the xml configuration file, which is almost the same for interface-oriented programming. After writing the interface, implement it and then call it.

Interfaces are meaningless if they are not implemented.



IAvocationMapper.xml



The whole call is completed, and finally the program will return to the controller method in step 4 to return to the page


Page jump to see what page you want to jump to. This jump spingmvc configuration file: that is, try parser, it will automatically map to you spell web-inf/jsp/admin/avcationAdd.jsp,


Well, this is the basic process of adding, deleting, modifying and checking the entire ssm. If there is something wrong or incomprehensible, please leave a message below, or contact my qq 112972968. I will update it next time. The basic process of ssh, let you feel the difference between the two frameworks, and the advantages of ssm

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324524144&siteId=291194637