Introduction to SSH Framework

What is SSH

SSH is an integration framework of struts + Spring + hibernate. It is a popular open source framework for web applications. SSH is not a framework, but closely combines multiple frameworks (struts, spring and Hibernate) to build flexible and easily extensible multi-layer web applications.

The system of SSH framework is divided into four layers in terms of responsibilities: presentation layer, business logic layer, data persistence layer and domain module layer (entity layer).

Let's explain the relationship and contents of the three frameworks through the following figure. The contents have been very detailed, so we won't explain too much here.

Let's take a closer look at the three frameworks that make up SSH.

Struts

1. What is struts?

In terms of simplicity, struts is the simplest of the three frameworks. It is a framework based on MVC. It realizes the application framework of MVC design pattern based on Java EE web application by using javaservlet / JSP technology. It is a specific implementation of MVC or a specific product of MVC.

2. The core composition of struts

The core of struts is also the core of MVC. Struts is a specific product of MVC.

(1)Model

It is composed of action, ActionForm and JavaBean. ActionForm is used to encapsulate the parameters requested by users into ActionForm objects. We can understand it as an entity. Actionservlet forwards them to action. Action processes user requests and returns the processing results to the interface.

(2)View

This part uses JSP + a large number of taglib to realize the rendering of the page.

(3)Controller

Controller is the core controller of struts, which is responsible for intercepting user requests and realizing the function of processing user requests by calling model.

3. Why use struts?

Using struts as the overall infrastructure of the system is responsible for the separation of MVC and separating pages from business logic. Using pages is more flexible and will not affect business logic, which simplifies the development of web applications based on MVC, thus making the development more efficient.

Hibernate

1. What is Hibernate?

Hibernate is an object relational mapping framework, which encapsulates JDBC in a lightweight way, making us use the idea of object-oriented to operate relational databases.

2. Core composition of Hibernate

We won't explain this part too much. The explanation in the above guide map is very simple and clear. If you still don't understand it, you can check the relevant materials on the Internet.

3. Why use Hibernate?

(1) Hibernate is a lightweight object encapsulation of JDBC, which makes it easier to deal with relational databases.

(2) Objectification, which enables us to operate the relational database with the idea of object-oriented, simplifies the coding work of Dao layer, and makes the development more objectified.

(3) Better portability, support for various databases, it is extremely simple to replace the database, and there is no need to change the code.

(4) It implements transparent persistence, does not implement third-party frameworks or interfaces, and is not intrusive. It is a lightweight framework.

Spring

1. What is spring?

Simply put, spring is a lightweight inversion of control (IOC) and aspect oriented (AOP) container framework.

2. The core composition of spring

(1)IoC

IOC is IOC, not a technology, but a design pattern. Through dependency injection, spring manages and controls the dependencies between objects to avoid hard coding

Code caused by excessive program coupling.

(2)AoP

It is a technology to realize the unified maintenance of program functions through precompiled mode and runtime dynamic agent.

(3) Container

The container can manage the life cycle of objects and the dependencies between objects.

3. Why use spring?

Without spring, struts and Hibernate can run well. I call this mode "single wooden bridge", but with spring, struts and Hibernate can better combine and coordinate their work. I call this model "Sunshine Avenue". The core idea of spring is IOC and AOP. Spring makes it easier to manage objects, greatly reduces the coupling between components, and realizes the decoupling between software layers. There are many advantages of spring, so we won't dwell on it.

summary

SSH not only realizes the complete separation of view, controller and model, but also realizes the separation of business logic layer and persistence layer, which reduces the coupling degree, makes the system more flexible and reusable. At the same time, the framework provides us with some basic services, which makes our development simpler and greatly improves the development efficiency.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>