Struts: Responsible for the display layer, is a perfect MVC implementation, it calls the business layer to complete the operational logic, the business layer calls the persistence layer to complete the database read and write.
Hibernate: Creates a series of persisted classes that correspond to the properties of each class to the database table's property one by one.
Spring: relies on injection and control inversion. As soon as you get a class that implements this interface, you can easily inject the implementation class into the class that invokes the interface through an XML configuration file. This dependency between all classes is completely superseded by the configuration file.
Java Web Application Architecture: Struts is responsible for the display layer, hibernate is responsible for the persistence layer, and spring is responsible for the middle business layer.
In addition, because of the dependency injection and AOP (aspect-oriented programming) used by spring, this internal pattern is so good that spring itself implements an MVC framework that uses a dependency injection, called Spring MVC, and in order to handle things well, Spring integrates hibernate, enabling things to be managed from Hibernate's persistence layer to the business layer, which is more convenient and powerful to use.
The so-called three-tier development is the division of the entire business application of the system into "presentation layer-business logic Layer-data access layer"
1, Struts
Struts control files Struts-config.xml, action, and action Servlets implement MVC's controller, JavaBean or EJB to complete the model part of MVC, JSP pages assume the MV View component, And all the control logic is done with the Struts-config.xml configuration file.
STRUTS2 provides a rich interceptor implementation
2. Hibernate
Hibernate is a lightweight framework for the data persistence layer, which provides a very lightweight object encapsulation of JDBC, allowing Java programmers to use
Object programming thinking to manipulate the database. This paper provides a method for querying the data, using object-oriented thinking to manipulate the database, and save time for developing processing data.
Use some configuration files, such as Hibernate.cfg.xml, action and action files, XML Mapping (mapping files), on top of the physical database for application Systems
To provide data persistence services, while achieving the application of the persistence layer and the different physical database systems to isolate each other.
Hibernate Workflow:
Read and parse the configuration file;
The configuration is responsible for reading and creating the mapping information, creating session Factory
Sessionfactory is responsible for creating the session;
Transaction is responsible for opening the transaction transaction;
Query is responsible for performing persistent operations;
Transaction is responsible for submitting the transaction;
Close session and session factory;
Hibernate provides a level two cache, and the first level of cache is session-level caching, which is a transactional-wide cache. Managed by hibernate, usually without intervention. The second level of caching is the session factory level cache, which belongs to the process-wide or cluster-wide cache. Can be configured and changed, and can be loaded and unloaded dynamically.
3. Spring
Spring: The core container provides the basic functionality of the spring framework. The main component of the core container is the bean Factory, which is the implementation of the factory pattern. Bean Factory uses the inversion of control (IOC) pattern to separate the application's configuration and dependency specifications from the actual application code. Control inversion, or dependency injection, is the core of spring. Some kind of dependency between objects is injected by the container during operation, and the implementation of the relationship between the control program is given to the external container to complete.
Dependency injection exists in the 2 implementation mode:
1, set value injection is set injection
2. Construction Injection
Summarize:
Struts is used to represent the layer, directly facing the user, responding to a user's request, providing a model and a controller for the display, and delegating calls to functions such as business logic and other top-level processing.
Spring's unique capabilities in transaction management and dependency injection enable business logic and business validation for processing applications, and interfaces for interacting with other tiers.
Hibernate is an ORM (object-relational mapping) implementation that uses it to build a persistent object in the Java object model, which in turn makes it easy to manipulate relational databases in an object-oriented manner.
This allows struts, Spring, and hibernate to encapsulate all levels of the program, such as processing the foreground presentation layer without doping the transaction logic and persistence logic, thus maximizing the high cohesion and low coupling targets of each layer.
Struts + Hibernate + Spring web framework