The three frames of struts, hibernate, and spring are detailed.

Source: Internet
Author: User

For Struts control

Hibernate operations database.

Spring uses a decoupled

The role of Struts, spring and Hibernate in each layer

1) Struts is responsible for the Web tier.

Actionformbean receives the data submitted by the form in the Web page, then processes it through the Action and Forward it to the corresponding page.

The <ACTION-MAPPING> is defined in Struts-config.xml, and Actionservlet is loaded.

2) Spring is responsible for business layer management, i.e. service (or manager).

1. The service provides a statistical calling interface for the action, encapsulating the DAO for the persistence layer.

2. Can write some of their own business methods.

3. A unified approach to JavaBean management

4. Declarative transaction Management

5. Integrated Hiberante

3) Hiberante, responsible for persistence layer, complete the database crud operation

Hibernate is a persistent layer that provides or/mapping.

It has a set of. hbm.xml files and POJO that correspond to the tables in the database. Then you define DAO, which is the class that deals with the database, and they use the PO.

In the Struts+spring+hibernate system,

The calling process for an object is: Jsp-> Action-> Service->dao->hibernate.

The flow of data is Actionformbean accepts the user's data, the Action takes the data out of the Actionfrombean, encapsulates it into VO or PO,

Then call the business layer of the Bean class, complete a variety of business processing and then forward. When the business layer Bean receives the PO object, it invokes the DAO interface method for persistence.

SPRING:AOP Management Transaction Control, IOC manages the coupling of various components, daotemplate as a rapid development template for regular persistence layer!

Struts: Control layer Action, page label and model data, calling the business layer

Hibernate: Responsible for database and object mapping, the DAO layer (data Access object)

Spring integrates hibernate and struts, as long as the applicationcontext.xml is well-equipped and is called directly in the struts action. Hibernate access to the database is implemented in spring, and spring's call is implemented in the Stuts action.

The three frames of struts, hibernate, and spring are detailed.

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.