2017.10.13 three major frameworks for Java: struts+hibernate+spring

Source: Internet
Author: User
Tags aop to domain

• Definition: Java Three frameworks are mainly used for Wen applications. Struts is mainly responsible for the display of 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. (1) Struts framework: Struts is open source software. The purpose of using struts is to help us reduce the use of MVC design models tothe time the Web app was developed. Struts is a good choice if we want to mix the benefits of Servlets and JSPs to build scalable applications. (2) Spring framework: This is a powerful framework for solving many of the problems common in the development of Java EE. The Springle provides managementA consistent approach to business objects and encourages the injection of programming to the interface rather than the good habit of becoming a class. The Architecture foundation of Spring is based on the use of JavaBeanthe inversion of Control container for the property. Spring, however, uses the IOC container as a complete solution for building games that focus on all of the architectural layersis unique. Spring provides a unique data management abstraction that includes a simple and efficient JDBC framework, greatly improving efficiency and reducing the likelihoodthe error. Spring's data Access architecture also integrates hibernate and other O/R mapping solutions. (3) Hibernate framework: Hibernate is an object-relational mapping framework for open source code that awakens the Philadelphia Lightweight object encapsulation to JDBC,makes it possible for Java programmers to manipulate databases by using objects as they like. Hebernate can be used in any JDBC-for use in Java-based client programs, or to use the most revolutionary thing in servlet/jsp Web applications, hibernate can be used in the application of EJBThe Java EE Architecture replaces CMP and completes the task of data persistence.

Detailed Description:

1. Hibernate3 provides a lazy load feature for properties?

  When hibernate queries the data, the data does not exist in memory, and when the program actually operates on the data, the object is saved

With memory, deferred loading is achieved, which saves the server's memory overhead and improves server performance.

How does the relationship between classes be implemented in 2.Hibernate? (e.g. one-to-many, many-to-many relationships)

 The relationship between classes and classes is mainly manifested in the relationship between tables and tables, and they operate on objects in the city, and in our programs

All tables and classes are mapped together, using Many-to-one, One-to-many, many-to-many in the configuration file.

What is 3.JSF?

 JavaServer face is a component-based Web development framework, similar to the sturts framework;

4. What are the indexes and constraints within the database?

  Index is to improve the speed of data retrieval, the index is built on the data table, based on one or more fields to establish a constraint is for

To maintain the integrity of the data, constraints have non-null constraints, PRIMARY KEY constraints, foreign key constraints and so on.

5.Hibernate working principle and why use?

  Principle: (1). Read and parse the configuration file

(2). Read and parse mapping information, create Sessionfactory

(3). Open session

(4). Create Transaction Transation

(5). Persistent operation

(6). Commit a transaction

(7). Close Session

(8). Close Sesstionfactory

Reason:

(1). The code for JDBC access to the database is encapsulated, which greatly simplifies the tedious repetitive code of the data access layer.

(2). Hibernate is a JDBC-based, mainstream persistence framework that is an excellent ORM implementation. He simplifies the coding of the DAO layer to a great extent

(3). Hibernate uses the Java reflection mechanism rather than the bytecode enhancer to achieve transparency.

(4). Hibernate has a very good performance because it is a lightweight framework. The flexibility of the mapping is excellent. It supports a variety of relational databases, from one-to-one to many-to-many complex relationships.

How is 6.Hibernate delayed loading?

 1. Hibernate 2 Lazy Load Implementation: a) collection of entity object B) (Collection)

7.struts1 Process:

1. The client browser makes an HTTP request.

2, according to the Web. XML configuration, the request was Actionservlet received.

3, according to the Struts-config.xml configuration, actionservlet the parameters in the request to Actionform, and then actionservlet send the request to the action for processing.

4, whether to verify, need to verify the call Actionform's Validate method, the validation fails to jump to input, success continues.

5. Action obtains data from Actionform and invokes the business method in JavaBean to process the data.

6. Action returns the Actionforward object and jumps to the corresponding JSP page or action.

7. Returns the HTTP response to the client browser.

MVC design Pattern: modal: "Model" is also called business logic, is the code of the true completion of the task, quite with Javabeanview: view, is actually the display interface, equivalent to Jspcontroller: Controller, he controls the model and view of the interactive process, Equivalent to Servletstruts1 is based on the MVC design pattern hibernate is an ORM object-relational mapping

What is 8.struts?

Struts1 is an open-source Web application framework based on JSP and servlet, using the MVC design pattern struts2 is a framework based on webwork technology.

is a fully functional framework developed by Sun and WebWork, and struts2 and struts1 have nothing to do with the new framework.

What is 9.spring?

Spring is a hodgepodge of integrated third-party frameworks with the core technology of IOC (control inversion, also known as Dependency injection) and AOP (tangent-oriented programming)

What is 10.hibernate?

Hibernate is a tool for data persistence based on ORM Object Relational mapping (the mechanism of accomplishing object data to relational data mapping).

What is 11.spring?

This problem can often be cut through why we use Spring: AOP allows developers to create non-behavioral

Concerns, called crosscutting concerns, are inserted into the application code. With AOP, public services (such as logs, persistence, transactions, and so on)

Can be decomposed into facets and applied to domain objects without increasing the complexity of the object model of the domain object. IOC allows you to create an application environment that can construct objects.

These objects are then passed to their collaboration objects. As the word inversion shows, the IOC is like the reverse JNDI. Not using a bunch of abstract factories, service locator

Singleton and Direct constructs (straight construction), each object is constructed with its collaboration objects. Therefore, the collaboration object (collaborator) is managed by the container.

Spring even an AOP framework, is also an IOC container. The best part of Spring is that it helps you replace objects. With Spring, just use the JavaBean property and match the

Add dependencies to the file (collaboration object). You can then easily replace collaboration objects with similar interfaces when you need them.

12. Use your own words to briefly describe the STRUTS2 implementation process.

The Struts 2 framework itself can be broadly divided into 3 parts: The core controller filterdispatcher, the Business controller action, and the enterprise business logic components implemented by the user.

The core controller Filterdispatcher is the foundation of the Struts 2 framework and contains the control flow and processing mechanisms within the framework. Business controller action and business logic components are

Needs to be implemented by the user. While developing the action and business logic components, the user also needs to write the relevant configuration files for use by the core controller filterdispatcher.

The work flow of struts 2 is simpler than struts 1 and basically the same as the webwork framework, so struts 2 is the upgraded version of WebWork.

The basic brief flow is as follows:

1. The client browser makes an HTTP request.

2, according to the Web. XML configuration, the request was Filterdispatcher received.

3, according to the Struts.xml configuration, find the action class and method that need to be called, and through the IOC way, the value is injected to Aciton.

4. Action invokes the business logic component to process the business logic, which includes form validation.

5, the action is completed, according to the configuration in the Struts.xml to find the corresponding result of the return, and jump to the corresponding page.

6. Returns the HTTP response to the client browser.

2017.10.13 three major frameworks for Java: struts+hibernate+spring

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.