Eyes over times, better hand over over SSH in the EE project, 3 kinds of frameworks, namely Spring+struts+hibernate, were represented. Struts provides the corresponding components for both Model,view and controller. Spring is a lightweight control inversion (IOC) and facet-oriented (AOP) container framework that is created by Rod Johnson. It is created to address the complexities of enterprise application development. Spring uses basic JavaBean to accomplish things that were previously only done by EJBS. Hibernate is an open-source object-relational mapping framework that provides JDBC with a very lightweight object encapsulation that can be used in any JDBC scenario, in a serlet/jsp Web application, or in the Java EE architecture of the EJB application to replace the CMP. The task of achieving data persistence. The STRUST2 principle is to use interceptors so that requests sent by your clients are intercepted and processed. The interceptor is in the reflection mechanism. Struts2 main function is to control the forwarding, is the action of the processing, and Struts.xml configuration. Spring actually contains a lot of knowledge, the use of IOC,AOP and so on, is actually the management framework of the container, you do not have to consider your new object, it will help you do, reduce the layer and layer coupling degree. In spring there are many containers of thought, the IOC is control inversion, injected. AOP is facet-oriented and a bit like an interceptor. Hibernate is a persistent layer framework, we usually use the JDBC operation database will write SQL statements, and sometimes more than one field will be troublesome, so with hibernate is very convenient, as long as you master the mapping inside the relationship, you do not have to write SQL statements, it will help you write, API call is convenient.
Struts 1.Struts frame structure struts provides the corresponding components for both Model,view and controller. In the figure, Actionservlet, this class is the core controller of Strust, which is responsible for intercepting the user's request. Action, which is typically provided by the user, is responsible for receiving the request from Actionservlet and invoking the business logic method of the model to process the request and returning the processing results to the JSP page display. The 2.Model part consists of Actionform and JavaBean, wherein Actionform is used to encapsulate the user's request parameters, encapsulated as a Actionform object, which is forwarded by Actionservlet to the action, The action processes the user's request based on the request inside. The Javebean encapsulates the underlying business logic, including access to the database. 3.View part of this part uses the JSP implementation struts to provide the rich tag library, through the tag library can reduce the use of the script, the custom tag library can realize the effective interaction with the model, and adds the realization function. For the JSP portion of the image above.
The 4.Controller Component controller component consists of two parts-the system core controller, the business logic controller. The system core controller corresponds to the actionservlet of the above figure. The controller is provided by the Strust 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 the user's request. 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.
Spring 1. Introduction Objective: To solve the complexity of enterprise application development: The use of basic javebean instead of EJB, and provide more enterprise application functional scope: Any Java application simply, Spring is a lightweight control inversion (IOC) and facet-oriented (AOP) container framework. 2. In terms of both size and overhead, spring is lightweight. The full spring framework can be published in a jar file with a size of more than 1MB. And the overhead that spring needs to deal with is negligible. In addition, spring is non-intrusive: Typically, spring application objects do not depend on a particular class of spring. 3. Control reversal Spring facilitates loose coupling by means of a technique called inversion of control. When IOC is applied, the other objects that an object relies on are passed in passively, rather than the object itself creating or locating dependent objects. You can think of the IOC as opposed to Jndi--not the object looking for dependencies from the container, but the container actively passing the dependency to him when the object is initialized without waiting for the object to be requested.
4. Aspect-oriented spring provides rich support for aspect-oriented programming that allows for the development of cohesion by separating the business logic of the application from the system-level services (for example, Auditing (auditing) and Things (transaction) management). The Application object only implements what they should do--complete the business logic--that's all. They are not responsible (or even conscious) for other system concerns, such as log or thing support.
5. Container spring contains and manages the configuration and life cycle of the Application object, in this sense it is a container, and you can configure how each of your beans is created-based on a ready-to-use prototype (prototype), Your bean can create a separate instance or make a new instance of it each time it is needed-and how they relate to each other. However, spring should not be confused with traditional heavyweight ejb containers, they are often bulky and unwieldy and difficult to use. 6. The framework spring can combine simple component configurations into complex applications. In spring, application objects are combined declaratively, typically in an XML file. Spring also provides a number of basic functions (things management, persistence framework integration, etc.), leaving the development of application logic to you.
All of these features of spring enable you to write code that is cleaner, more manageable, and easier to test. They also provide basic support for the various modules in the spting.
Hibernate 1. Introduction Hibernate is an object-relational mapping framework for open source code, which provides a very lightweight object encapsulation of JDBC, allowing Java programmers to manipulate databases with the mind of object programming. Hibernate can be applied to any JDBC-ready application, either in a Java client program or in a servlet/jsp Web application, and it is revolutionary that hibernate can replace CMP with EJB's Java EE architecture. Complete the task of data persistence. Hibernate has a total of 5 core interfaces, namely: Session,seesionfactory,transaction,query and Configuration. These 5 core interfaces will be used in any development. Through these interfaces, not only the persistent objects can be accessed, but also to control things. These 5 core interfaces are described separately below. The session interface session interface is responsible for performing crud operations on persisted objects (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 Httpseesion in JSP applications. When the term "session" is used, it is actually referring to the session in Hibernate, which will later be the user session of the HttpSession object. The Sessionfactory interface Sessionfactory interface is 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 usually requires only one sessionfactory, and when you need to manipulate multiple databases, you can specify a sessionfactory for each database. The Configuration Interface Coinfiguration interface is responsible for configuring and starting Hibernate, creating Sessionfactory objects. In Hibernate's Startup object, the instance of the configuration class first locates the mapped document location, reads the configuration, and then creates the Sessionfactoty object. The transaction interface transaction interface is responsible for things-related operations. It is optional, and developers can also design and write their own underlying object processing code. The query and Criteria interface is responsible for the query and Criteria interfacesPerform a variety of database queries, which can be expressed in HQL language or SQL statement form.
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.