Listen to the three main framework, about the three framework, did the following understanding:
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
And then use the JSP servlet to do web page development when there is a mapping file of XML, there is a mapping tag is used to do file mapping. When you enter the URL in the browser to know, the file will be based on the name you write to a Java file, according to the content written in the Java file displayed in the browser, is a Web page.
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 components for 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 as Actionform object, the object is Actionservlet forwarded to the action, The action processes the user's request based on 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. 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. The business logic controller, which is responsible for processing user requests, does not have the processing power, but calls 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. Springle provides a consistent approach to managing business objects and encourages the injection of programming to interfaces rather than the good habit of becoming a class. 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 applied to any JDBC application, either in Java client programs or in servlet/jsp Web applications, and hibernate can replace CMP in the EE architecture of the EJB application. The task of achieving 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: A CRUD operation that is responsible for executing a persisted object (the task of crud is to complete the communication with the database, including many common SQL statements. )。 However, it is important to note that the session object is non-thread-safe. At the same time, Hibernate's session differs from the HttpSession in JSP applications. When the term "session" is used, it is actually referring to the session in Hibernate, and later the HttpSession object is called the user session.
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 you need to manipulate multiple databases, you can specify a sessionfactory for each database.
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.
Introduction to the three main frameworks of Java