(1) Struts mainly plays the role of control, spring mainly escorts the coupling effect, hibernate mainly plays the role of operation data.
(2) The core of struts is controller (i.e. Actionservlet), and the core of Actionservlet is the processing of Struts-config.xml main control logic relationship.
(3) Spring is a lightweight control inversion (IoC) and aspect-oriented (AOP) container framework that is lightweight, non-intrusive, interface-oriented, and (dependent) relationships between container control programs, when other objects dependent on an IoC object are transmitted in a passive manner, Instead of creating or locating dependent objects on this object itself. Dependency injection, that is, the dependencies between components are determined by the container at run time, that is, the main function of the container to inject a dependency into the component dynamically is decoupling.
(4) Hibernate is a data persistence layer, a new mapping tool for objects and relationships, provides a mapping from Java classes to data tables, and provides mechanisms for querying and recovering data, which greatly reduces the complexity of data access. Converts the direct operation of a database to the operation of a persisted object.
(5) The role of Struts, Spring, hibernate in each layer:
<1>struts is responsible for the Web layer, Actionformbean receives the data submitted by the form in the Web page and then processes it through action, then forward to the corresponding Web page, defined in Struts-config.xml < Action-mapping>actionservlet will load.
<2>spring is responsible for business layer management, i.e. service or manager.
[1] The service layer provides a statistical calling interface for the action, encapsulating the DAO for the persistence layer.
[2] Unified management JavaBean method.
[3] Declarative transaction management.
[4] Integrated hiberante.
<3>hiberante is responsible for the persistence layer to complete the CRUD operations of the database, providing or-mapping for the persistence layer, which has a set of *.hbm.xml files and pojo corresponding to the tables in the database.
<4> the call flow for objects in Struts + Spring + Hibernate is jsp->action->service->dao->hibernate. The flow of data is Actionformbean accept the user's data, the action takes the data out of the Actionfrombean, encapsulates it into VO or PO, and then calls the business layer's bean class, completing various business processing and then forward. When the business layer bean receives the PO object, it calls the DAO interface method for persistence.
What are the roles of Struts2, Spring, and hibernate in the SSH project?