The working principle and process of the three major frameworks of SSH

The content comes from: Interview & written test questions of the three frameworks of Struts, Spring and Hibernate

 

1. How hibernate works:

  • Read and parse configuration files
  • Read and parse mapping information, create sessionFactory
  • open session
  • Create transaction transaction
  • Endurance operation
  • commit transaction
  • close session
  • close sessionFactory

    Why use:

  • The code for JDBC access to the database is encapsulated, which greatly simplifies the cumbersome and repetitive code of the data access layer.
  • It is a mainstream persistence framework based on jdbc, an excellent ORM implementation, which greatly simplifies the coding of the DAO layer
  • Transparency using Java reflection mechanisms instead of bytecode enhancers
  • It is a lightweight framework with excellent mapping flexibility and supports various relational databases, from one-to-one to many-to-many complex relationships

 

2. How does hibernate implement lazy loading?

  • hibernate2 lazy loading implementation: a. entity object b. collection
  • hibernate3 provides lazy loading of properties
  • When hibernate is querying data, the data does not exist in the memory. When the program actually operates on the data, the object exists in the memory, which realizes lazy loading, which saves the memory overhead of the server and improves the performance of the server.

3. How to realize the relationship between classes in hibernate

  • The relationship between classes is mainly reflected in the relationship between tables and tables. They all operate on objects. In our program, all tables and classes are mapped together. They pass the many-to in the configuration file. -one, one-to-many, many-to-many

4. Talk about the caching mechanism of hibernate

  • The memory cache exists in hibernate, also called the first-level cache, which belongs to the application transaction-level cache
  • Level 2 cache: a) Application and cache b) Distributed cache c) Implementation of third-party cache

 

5.Struts working mechanism:

  • Workflow: When the web application starts, it will load and initialize ActionServlet. ActionServlet reads configuration information from struts-config.xml file and stores them in various configuration objects.
  • When ActionServlet receives a client request, it will perform the following process:
  1. Retrieve the ActionMapping instance that matches the user's request. If it does not exist, return the request path invalid information;
  2. If the ActionForm instance does not exist, create an ActionForm object and save the form data submitted by the customer in the ActionForm object;
  3. Determine whether form validation is required according to the configuration information. If validation is required, call the validate() method of ActionForm;
  4. If the validate method of ActionForm returns null or returns an ActionErrors object that does not contain ActionMessage, it means that the form validation is successful;
  5. ActionServlet decides which Action to forward the request to according to the mapping information contained in ActionMapping. If the corresponding Action instance does not exist, it will first create this instance, and then call the Action's execute method;
  6. The execute method of Action returns an ActionForward object, and ActionServlet forwards the client request to the JSP component pointed to by the ActionForward object;
  7. The ActionForward object points to the JSP component to generate a dynamic web page and returns it to the client;
  • Why use struts:
    • The emergence of JSP, Servlet, JavaBean technology provides us with the possibility to build a powerful enterprise application system. But the system built with these technologies is very complicated, so on top of this, we need a rule, a rule to organize these technologies, this is the framework, and Struts came into being
    • An application developed based on Struts consists of three types of components: controller components, model components, and view components

6.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324973003&siteId=291194637