search
HomeJavajavaTutorialWhat are the three major frameworks of java

Struts, Hibernate and Spring are commonly used keys in our Java development. They provide the most appropriate solutions for different application scenarios. But do you know how these well-known frameworks originally came about?

Recommended course: Java Tutorial.

What are the three major frameworks of java

We know that traditional Java Web applications are implemented using JSP Servlet Javabeans. This model implements the most basic MVC layering, making the program structure divided into There are several layers, including JSP responsible for front-end display, Servlet responsible for process logic control, and Javabean responsible for data encapsulation. However, there are still problems with this structure: for example, JSP pages need to use symbols to embed a lot of Java code, resulting in a confusing page structure. Servlets and Javabeans are responsible for a lot of jumps and calculations, tight coupling, low program reusability, etc.

The three major frameworks of java are:

1. Struts

In order to solve these problems, the Struts framework appeared, which It is a perfect MVC implementation. It has a central control class (a Servlet). For different businesses, we need an Action class to be responsible for page jumps and background logic operations, and one or several JSP pages to be responsible for data input and output display. , there is also a Form class responsible for passing data between Action and JSP. A set of tags provided by the Struts framework can be used in JSP, which is as simple as using HTML tags, but can complete very complex logic. From now on, there is no need to have a line of surrounding Java code in the JSP page.

However, placing all the operation logic in the Action of Struts will make the Action class less reusable and the logic confusing. Therefore, people usually divide the entire Web application into three layers. Struts is responsible for the display layer. The business layer is called to complete the operation logic, and the business layer then calls the persistence layer to complete the reading and writing of the database.

Use JDBC connection to read and write the database. The most common thing we do is to open the database connection, use complex SQL statements to read and write, and close the connection. The obtained data needs to be converted or encapsulated and then transmitted to the outside. This is a Very cumbersome process.

2. Hibernate

The Hibernate framework appears at this time, which requires you to create a series of persistence classes. The attributes of each class can be simply viewed as It has a one-to-one correspondence with the attributes of a database table. Of course, it can also be associated with various table files in a relational database. When we need related operations, we no longer need to pay attention to the database table. We no longer need to query the database line by line. We only need the persistence class to complete the functions of addition, deletion, modification and query. Make our software development truly object-oriented rather than messy code-oriented. My feeling is that using Hibernate reduces the amount of programming by 80% compared to JDBC.

Now we have three layers, but what are the calls between each layer? For example, if Struts in the display layer needs to call a business class, it needs to create a new business class and then use it; if the business layer needs to call the persistence layer class, it also needs to create a new persistence layer class. Calling each other through this new method is the embodiment of the worst design in software development. To put it simply, the caller depends on the callee, and a strong coupling is formed between them. If I want to reuse a class elsewhere, other classes that this class depends on also need to be included. The program becomes very confusing, each class depends on each other and calls each other, and the degree of reusability is extremely low. If a class is modified, many classes that depend on it will be affected. For this purpose, the Spring framework appears.

3. Spring

The function of Spring is to completely decouple the dependencies between classes. If a class depends on something, it is an interface. As for how to implement this interface, it doesn't matter. As long as you get a class that implements this interface, you can easily inject the implementation class into the class that calls the interface through the xml configuration file. This dependency between all classes is completely replaced by configuration files. So the core of the Spring framework is the so-called dependency injection and control inversion.

The current structure is that Struts is responsible for the display layer, Hibernate is responsible for the persistence layer, and Spring is responsible for the middle business layer. This structure is currently the most popular Java Web application architecture in China. In addition, because Spring uses dependency injection and AOP (aspect-oriented programming), its internal model is so excellent that Spring itself has also implemented an MVC framework that uses dependency injection, called Spring MVC. At the same time, for good To handle things, Spring integrates Hibernate, which elevates transaction management from Hibernate's persistence layer to the business layer, making it more convenient and powerful to use.

The Struts framework started in 2000, and the technology is quite mature. Currently, the Struts framework is the undisputed king of display layer technology in global Java development. It has a large user base and a good development team. This is also the basic requirement for new employees by most domestic Java software companies.

other

The term Java seems destined to be closely associated with open source. In the Java world, a large number of open source technologies appear every day. Since it is open source, the problems and shortcomings in the technology will soon be discovered. , open source software providers will quickly modify or expand these technologies, so the version is updated quickly, and a new version will be released in a few weeks or days.

When we choose Java in the technical line, we also choose that you must continue to learn, always pay attention to the latest technologies, understand them, see if they suit your needs, and then learn to use them.

The combination of Java's SSM is also very good, and everyone can learn about it.

The above is the detailed content of What are the three major frameworks of java. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log?How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log?Apr 19, 2025 pm 11:45 PM

Start Spring using IntelliJIDEAUltimate version...

How to elegantly obtain entity class variable names to build database query conditions?How to elegantly obtain entity class variable names to build database query conditions?Apr 19, 2025 pm 11:42 PM

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

How to use the Redis cache solution to efficiently realize the requirements of product ranking list?How to use the Redis cache solution to efficiently realize the requirements of product ranking list?Apr 19, 2025 pm 11:36 PM

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

How to safely convert Java objects to arrays?How to safely convert Java objects to arrays?Apr 19, 2025 pm 11:33 PM

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

How do I convert names to numbers to implement sorting and maintain consistency in groups?How do I convert names to numbers to implement sorting and maintain consistency in groups?Apr 19, 2025 pm 11:30 PM

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products?E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products?Apr 19, 2025 pm 11:27 PM

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to set the default run configuration list of SpringBoot projects in Idea for team members to share?How to set the default run configuration list of SpringBoot projects in Idea for team members to share?Apr 19, 2025 pm 11:24 PM

How to set the SpringBoot project default run configuration list in Idea using IntelliJ...

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)