Spring of the "Java Interview" framework

Source: Internet
Author: User
Tags aop rollback

1. How do you understand spring?

In particular, spring is a lightweight container for managing business-related objects. The core function is mainly: IOC,AOP,MVC.

IOD: Control reversal, the creation of the object to the container, so that the container to manage the life cycle of objects such as creation, initialization, destruction and so on.

AOP: Aspect-oriented programming, the focus of the modular, through a function point programming, such as logging, there are many classes need to log the method, then create a log of the proxy method, you need to call the function is to call the proxy method, this is AOP.

Mvc:springmvc,spring provides a web framework based on the MVC pattern design, one of the more popular frameworks today.


2.spring Configure how the bean is instantiated.

1 Use class constructor instantiation (default no parameter) <bean id= "Bean1" class= cn.itcast.spring.b_instance. Bean1 "></bean> 2" uses static Factory method instantiation (Simple Factory mode)//The meaning of this configuration: Call Bean2factory getBean2 method get bean2 <bean id= "Bean2" Class= "Cn.itcast.spring.b_instance. Bean2factory "factory-method=" getBean2 "></bean> 3" instantiate using instance Factory method (factory method mode)//Create factory instance Bean3facory first, Then create the target bean instance <bean id= "Bean3factory" class= cn.itcast.spring.b_instance from the factory instance. Bean3factory "></bean> <bean id=" bean3 factory-bean= "bean3factory" factory-method= "GetBean3" ></ Bean>

3. Introduce spring's management of things

A transaction is a uniform commit or rollback of a series of database operations, such as inserting more than one piece of data, if the insert succeeds, it succeeds together, and if there is an exception in the middle, then all operations before the rollback are rolled back. This prevents dirty data from appearing and prevents problems with database data.

In development, transaction management is generally done to avoid this situation. Spring also has its own transaction management mechanism, which is typically managed using Transactionmananger, which can be done through spring injection.

Spring supports transaction management in the following two ways:

Programmatic transaction management: This means that you can manage transactions programmatically, which offers great flexibility but is difficult to maintain.

Declarative transaction management: This means that you can separate transaction management from business code. You only need to use annotations or XML configuration to manage transactions.

General selection declarative transaction management, because this approach is less associated with the application.

4.Bean injection properties are available in several ways.


5. Describe SPRINGMVC workflow


Process
1, the user sends the request to the front-end controller Dispatcherservlet
2, Dispatcherservlet received the request to call the Handlermapping processor mapper.
3. The processor mapper finds a specific processor, generates the processor object and the processor interceptor (if any) is returned to the Dispatcherservlet.
4, Dispatcherservlet call Handleradapter processor Adapter
5, Handleradapter is adapted to call the specific processor (Controller, also known as back-end controller).
6, controller execution complete return Modelandview
7, Handleradapter will controller execution result Modelandview return to Dispatcherservlet
8. Dispatcherservlet will pass Modelandview to Viewreslover view parser
9, viewreslover after the resolution to return to the specific view
10. Dispatcherservlet The view for rendering (the model data is populated into the view).
11, Dispatcherservlet response users


The main difference between 6.SpringMVC and Struts2. the entrance to the ①SPRINGMVC is a servlet, the front-end controller, and the Struts2 Inlet is a filter filter. ②SPRINGMVC is based on the method of development, passing parameters are through the method parameter, can be designed as a single case or multiple cases (recommended single case), Struts2 is based on class development, passing parameters are through the properties of the class, can only be designed as many examples.
③struts uses the value stack to store the request and the response data, through the OGNL Access data, SPRINGMVC the Request object content to parse into the method parameter by the parameter parser, the response data and the page are encapsulated into the Modelandview object, Finally, the model data is transferred to the page through the request object. The JSP view parser uses Jstl by default.
What design patterns are used in 7.Spring. 1. Factory mode (beanfactory) 2. Single case mode (default Bean in Spring is single) 3. Adapter mode (Handleradater) 4. Decorator Mode 5. Proxy mode (JDK dynamic proxy used in AOP) 6. Observer patterns (listener implementations, such as Applicationlistener) 7. A policy pattern that defines a series of algorithms, encapsulates them one by one, and enables them to be interchangeable. Used when instantiating an object 8. Template mode (JdbcTemplate)
)

Related Article

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.