For Java web Programmer, Java Three framework: Struts+hibernate+spring understanding must be indispensable, the following detailed talk about Java Three framework is mainly used to do wen applications.
Three main frames: struts+hibernate+spring
The three main frameworks of Java are used to make Wen applications.
Struts is primarily responsible for displaying the presentation layer
Spring uses its IOC and AOP to handle the control business (responsible for the operation of the database)
Hibernate is primarily data persistence to the database
One. Struts framework: Struts is open source software.
Struts is used to help us reduce the time it takes to develop Web applications using the MVC design model. struts is a good choice if we want to mix the benefits of Servlets and JSPs to build scalable applications.
1. Process: After the server starts, read the struts-config.xml file contents to memory according to Web. XML load actionservlet .
2. Architecture: Struts provides the corresponding componentsfor both Model,view and controller . Actionservlet, this class is the core controller of Struts and is responsible for intercepting requests from users.
Model part: composed of JavaBean ,actionform used to encapsulate the user's request parameters, encapsulated into actionform object, the object is Actionservlet forwarded to action,action to process the user's request according to the request parameters inside the actionfrom . The JavaBean encapsulates the underlying business logic, including database access.
View section: This part is implemented by JSP . Struts provides a rich library of tags that can reduce the use of scripts through a tag library, and a custom tag library enables effective interaction with the Model and adds real-world functionality. The corresponding JSP part.
Controller components: Controller components are composed of two parts-the system core controller, the business logic controller.
(1) System core Controller, corresponding to the Actionservlet. The controller is provided by the Struts framework and inherits the HttpServlet class, so it can be configured as a callout Servlet. The controller is responsible for intercepting all HTTP requests and then deciding whether to transfer to the business logic controller based on user requests.
(2) The business logic controller, which is responsible for processing the user request, does not have the processing power, but calls the Model to complete processing. Corresponds to the Action section.
Two Spring Framework
Spring is a powerful framework that solves many of the problems that are common in the development of Java EE . Spring provides a consistent approach to managing business objects and encourages the injection of interface programming rather than the good habits of the classes. The schema base of Spring is based on the inversion of Control container that uses the JavaBean property. However, Spring is unique in using the IoC container as a complete solution for building play that focuses on all architectural layers. Spring provides a unique data management abstraction that includes a simple and efficient JDBC framework that greatly improves efficiency and reduces possible errors. Spring 's data Access architecture also integrates Hibernate and other O/R mapping solutions.
Three Hibernate framework
Hibernate is an object-relational mapping framework for open source code, and the Philadelphia Lightweight object encapsulation is awakened to JDBC , allowing Java programmers to manipulate databases with arbitrary objects. hebernate can be used in any JDBC application, either in Java client programs or in servlet/jsp Web Using the most revolutionary thing in the application , Hibernate can replace CMPin the Java EE architecture of the EJB application to complete the task of data persistence.
Hibernate has a total of 5 core interfaces:Session, Sessionfactory, Transaction, Query , and Configuration . These 5 core interfaces will be used in any development. Through these interfaces, you can not only access persistent objects, but also enable transaction control.
These five core interfaces are described separately below:
1. session Interface : Responsible for executing the crud operation of the persisted object ( The task of crud is to complete the communication with the database, which contains many common SQL statements. )。 However, it is important to note that the session object is non-thread-safe. At the same time, hibernate jsp session is a term that actually refers to session , and later will httpsession object is called user
2. Sessionfactory Interface : responsible for initializing Hibernate. It acts as a proxy for the data storage source and is responsible for creating Session objects. The factory model is used here. It is important to note that Sessionfactory is not lightweight, because in general, a project typically requires only one sessionfactory , and when multiple databases are needed, you can specify one for each database Sessionfactory.
3. Configuration Interface : Responsible for configuring and starting Hibernate, creating sessionfactory objects. During Hibernate startup, the instance of the configuration class first locates the map document location, reads the configuration, and then creates the sessionfactory object.
4. Transaction Interface : responsible for transaction-related operations. It is optional, and developers can also design their own underlying transaction-processing code.
5. Query and Criteria interface : responsible for executing various database queries. It can be expressed in either the HQL language or the SQL statement.
A master image metaphor: Struts is the Web Development Box Cutter (responsible for form submission) (equivalent to computer graphics card) Hibernate is responsible for the operation of the database (equivalent to the computer CPU) Spring equivalent to a motherboard (the video card and CPU are assembled together)
On the road of learning should go forward, don't be afraid of losing face. Do not understand is not understand, admit what will happen?? Admit to start learning Bai ~ ~ ~ ~ ~ ~ Forgot to review, so as to become a true master.
Discuss the three frames of struts+hibernate+spring