Home Common Problem What is the principle and process of ssm framework?

What is the principle and process of ssm framework?

Jul 18, 2020 pm 05:49 PM
process

The principle of the ssm framework is to integrate Spring, SpringMVC, and MyBatis as a framework for web projects with relatively simple data sources. The process is: Handler Mapping finds the corresponding Handler according to the request, calls the business logic for processing, and then performs view parsing.

What is the principle and process of ssm framework?

SSM Framework Introduction
SSM (Spring SpringMVC MyBatis) framework set consists of two Spring and MyBatis Integrated with open source frameworks (SpringMVC is part of Spring). SSM is often used as a framework for web projects with simple data sources.

SpringMVC
SpringMVC intercepts user requests in the project. Its core Servlet, DispatcherServlet, assumes the responsibility of an intermediary and matches user requests to the Controller through HandlerMapping. The Controller is the operation performed by the specific corresponding request.
SpringMVC framework running process

The user sends the request to DispatcherServlet;
DispatcherServlet receives the request and queries one or more HandlerMapping to find and process the request Handler;
HandlerMapping finds the corresponding Handler according to the request, generates a Handler object and returns it to DispatcherServlet;
DispatcherServlet calls Handler through HandlerAdapter;
Handler (Controller) calls business logic (service) for processing, and returns to ModelAndView after processing is completed ;
HandlerAdapter returns the Handler processing result ModelAndView to DispatcherServlet;
DispatcherServlet queries one or more ViewReslover (view resolvers) and passes the ModelAndView to the specified ViewReslover;
After the ViewReslover is parsed, it returns the specific View to DispatcherServlet;
DispatcherServlet renders the View (populates the model data into the view);
DispatcherServlet responds to the user, and the View displays the results on the client.
The process is roughly as shown below:

What is the principle and process of ssm framework?

DispatcherServlet is the core of the entire Spring MVC. It is responsible for receiving HTTP requests, organizing and coordinating the various components of Spring MVC, and its main work There are the following three items:
a. Intercept URL requests that match a specific format;
b. Initialize the WebApplicationContext corresponding to the DispatcherServlet context and associate it with the WebApplicationContext of the business layer and persistence layer;
c. Initialization Each component of Spring MVC is assembled into DispatcherServlet.
Spring
Spring is like a big factory that assembles beans in the entire project. In the configuration file, you can specify the use of specific parameters to call the constructor of the entity class. Instantiate the object. It can also be called the glue in the project.
The core idea of ​​Spring is IOC (Inversion of Control), which means that programmers no longer need to explicitly new an object, but let the Spring framework do it all for you. The IOC container is responsible for instantiating, locating, configuring objects in the application and establishing dependencies between these objects. The purpose of Spring is to ensure that the relationship between objects (modules and modules) is not related through code, but is managed through configuration class descriptions (Spring dynamically assembles objects internally through reflection based on these configurations).
The IOC container represents the BeanFactory interface in the org.springframework.beans package, which provides the basic functions of the IOC container; and the ApplicationContext interface under the org.springframework.context package extends the BeanFactory and also provides integration with Spring AOP. , internationalization processing, event propagation and providing different levels of context implementation.
Simply put, BeanFactory provides the most basic functions of the IOC container, while ApplicationContext adds more support for enterprise-level functions. ApplicationContext fully inherits BeanFactory, so the semantics of BeanFactory also apply to ApplicationContext.
Spring running process

Load configuration file, ApplicationContext interface. The bean information in the configuration file is loaded into the HashMap. A bean usually includes id, class, property, etc. The id of the bean corresponds to the key in the HashMap, and the value in the HashMap is the bean.
Call the getBean method. getBean is used to obtain the bean in the applicationContext.xml file. The parameter is the id of the bean. In general, it will be forced to convert to the corresponding business layer (interface).
Call the method of the business layer (interface implementation).
How is the content in the bean injected? To put it simply, when a bean is instantiated, the class is actually instantiated. It calls the set method in the class through reflection to inject the class attributes previously saved in the HashMap into the class. This brings us back to the original place of Java, object.property, object.method.
Mybatis
Mybatis is an encapsulation of jdbc, which makes the underlying operations of the database transparent. Mybatis operations all revolve around a sqlSessionFactory instance. Mybatis is associated to the Mapper file of each entity class through the configuration file. The Mapper file is configured with the SQL statement mapping required for each class to the database. Every time you interact with the database, get a sqlSession through sqlSessionFactory, and then execute the sql command.
Mybatis dynamically proxies dao through MapperProxy. That is to say, when executing the method in the dao written by yourself, the corresponding MapperProxy is actually acting as the proxy.
Mybatis operating principle

Loading configuration file
Load SQL configuration information into MappedStatement objects one by one, including parameter mapping configuration, execution SQL statements, resulting mapping configuration, are stored in memory.
SQL parsing
When the API interface layer receives the call request, it will receive the ID of the incoming SQL and the incoming object (can be Map/JavaBean or basic data type), and Mybatis will find the corresponding one based on the ID of the SQL. MappedStatement, and then parsed according to the incoming parameter object MappedStatement. After parsing, the SQL statement and parameters to be ultimately executed can be obtained.
SQL execution
Get the final SQL and parameters into the database for execution, and get the results of operating the database.
Result Mapping
Convert the results of operating the database according to the mapping configuration, which can be converted into HashMap/JavaBean or basic data types, and return the final result.

The above is the detailed content of What is the principle and process of ssm framework?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to open multiple Toutiao accounts? What is the process for applying for a Toutiao account? How to open multiple Toutiao accounts? What is the process for applying for a Toutiao account? Mar 22, 2024 am 11:00 AM

With the popularity of mobile Internet, Toutiao has become one of the most popular news information platforms in my country. Many users hope to have multiple accounts on the Toutiao platform to meet different needs. So, how to open multiple Toutiao accounts? This article will introduce in detail the method and application process of opening multiple Toutiao accounts. 1. How to open multiple Toutiao accounts? The method of opening multiple Toutiao accounts is as follows: On the Toutiao platform, users can register accounts through different mobile phone numbers. Each mobile phone number can only register one Toutiao account, which means that users can use multiple mobile phone numbers to register multiple accounts. 2. Email registration: Use different email addresses to register a Toutiao account. Similar to mobile phone number registration, each email address can also register a Toutiao account. 3. Log in with third-party account

Are Douyin sleep anchors profitable? What are the specific procedures for sleep live streaming? Are Douyin sleep anchors profitable? What are the specific procedures for sleep live streaming? Mar 21, 2024 pm 04:41 PM

In today's fast-paced society, sleep quality problems are plaguing more and more people. In order to improve users' sleep quality, a group of special sleep anchors appeared on the Douyin platform. They interact with users through live broadcasts, share sleep tips, and provide relaxing music and sounds to help viewers fall asleep peacefully. So, are these sleep anchors profitable? This article will focus on this issue. 1. Are Douyin sleep anchors profitable? Douyin sleep anchors can indeed earn certain profits. First, they can receive gifts and transfers through the tipping function in the live broadcast room, and these benefits depend on their number of fans and audience satisfaction. Secondly, the Douyin platform will give the anchor a certain share based on the number of views, likes, shares and other data of the live broadcast. Some sleep anchors will also

The mission strategy guide for the Collapsed Star Dome Railway through the Shadow of Death The mission strategy guide for the Collapsed Star Dome Railway through the Shadow of Death Mar 28, 2024 pm 01:10 PM

What to do when traveling through the Shadow of Death on the Collapsed Star Dome Railway? Walking through the Shadow of Death is one of the main quests [Cat among Doves], and it is also the final stage of the main quest. Below, the editor will provide a detailed explanation of the mission of Walking through the Shadow of Death on the Collapsed Star Dome Railway, for those who are interested. Come and take a look. 1. After completing the previous stage of the plot, you will be automatically transferred to the location in the picture below. After talking to March 7, you will enter the dungeon. Remember to form a team. 2. The backup plan is to fight [Stone Heart Ten] Weird Placer Gold, with four teams. The best character tactics and finishing skills are group attacks, and it is best to bring a shield and milk. This [Stone Heart Ten] strange sand gold is difficult to hit. When rolling the dice, if your points are greater than the sand gold, you will not be beaten. And after the end, the amount of finishing skills will be fully restored. If it is less than that, you will be beaten, so try to bring a group attack character to gain points. in boss

All the sad stories of the Collapsed Star Railroad mission strategy guide All the sad stories of the Collapsed Star Railroad mission strategy guide Mar 28, 2024 pm 01:26 PM

What to do with all the sad stories of the Collapsed Star Dome Railway? All Sad Stories is part of the main quest [Cat among Pigeons]. The process at this stage is relatively long. Below, the editor will provide a detailed explanation of the All Sad Stories quest on the Collapsed Star Dome Railway. Friends, please take a look. 1. After completing the previous stage, you will be automatically transferred to the second new map [Cloak Film and Television Park]. Follow the mission all the way from 1 [Pinball Machine] to 2 location and follow the third character. After completing the plot, go to Talk to the child in the 4th position and complete the mini-game [Speed ​​and Nuts]. A mini-game similar to Tiantian Cool Run is very simple. 3. Then the tracking task is to fly from position 1 [pinball machine] in the picture below to position 2 4. After arriving at the position in the picture below, you need to walk through the maze. After entering from the left, keep walking to the right to reach task point 15.

Detailed explanation and optimization strategy of php-fpm request processing process Detailed explanation and optimization strategy of php-fpm request processing process Jul 07, 2023 pm 01:52 PM

Detailed explanation and optimization strategy of php-fpm request processing process 1. Introduction In web application development, PHP is a very popular server-side scripting language. And php-fpm (FastCGIProcessManager) is a manager of PHP, used to process PHP requests. This article will introduce the request processing process of php-fpm in detail, and discuss how to optimize php-fpm and improve the performance of web applications. 2. php-fpm request processing process When the client initiates a request

Vue development experience sharing: experience in optimizing development process and work efficiency Vue development experience sharing: experience in optimizing development process and work efficiency Nov 22, 2023 am 10:53 AM

Vue.js is a popular JavaScript framework for building user interfaces and single-page applications. Its concise syntax, flexibility and powerful functions make it the first choice of many developers. In recent project development, my team and I have accumulated some experience in optimizing development processes and work efficiency, which we would like to share with you. First of all, as the basis for Vue.js development, we must fully understand the ecosystem and core concepts of Vue.js. The core concepts of Vue.js include data-driven and component systems

Introduction to software development process in Java language Introduction to software development process in Java language Jun 10, 2023 am 11:07 AM

The Java language is a widely used object-oriented programming language and is widely used in enterprise-level software development. In the Java language, the software development process is a very important part, which can help the development team complete software development tasks more efficiently. This article will introduce the software development process in the Java language and discuss the tasks to be completed at each stage. Requirements Analysis Phase The first step in software development is to conduct requirements analysis, which is aimed at determining the software requirements. During the requirements analysis phase in Java language, the development team needs

Basic process of building big data applications using PHP Basic process of building big data applications using PHP May 11, 2023 pm 04:58 PM

In recent years, with the explosive growth of data volume, the demand for big data applications is increasing. As a popular programming language, PHP is widely used in web development and can also be used to build big data applications. This article will introduce the basic process of building big data applications using PHP, including data processing, storage and analysis. 1. Data processing Data processing is the first step in big data application. Its purpose is to collect data from various sources and conduct preliminary processing and cleaning for storage, analysis and use. PHP can be used