Simple answers to three questions

Understanding of springIOC

  1. IoC (Inversion of Control): Inversion of Control. It is a design pattern, the spring framework is responsible for controlling the life cycle of objects and the relationship between objects
  2. Four characteristics of Spring:
    1. lightweight
    2. Dependency injection: Dynamically provide an object with other objects it needs while the system is running
    3. Aspect-Oriented Programming
    4. is a container
  3. In applicationContext.xml by injecting
  4. SpringIOC can manage the life cycle of beans. The management process is:
    1. Create bean instance via constructor or factory method
    2. By assigning a value to the bean's object
    3. Call the bean's initialization method

Understanding of SpringMVC

  1. MVC(Model, View and Controller)
  2. SpringMVC is a Java-based lightweight web framework that implements the request-driven type of the Web MVC design pattern. It uses the idea of ​​the MVC architecture pattern to decouple the responsibilities of the web layer. Request-driven refers to the use of request ( Request)-Response (Response) model, the purpose of the framework is to help us simplify development.
  3. SpringMVC process description:
    1. The user sends a request to the server, which is captured by the front controller DispatcherServlet
    2. DispatcherServlet parses the request URL and obtains the request resource identifier (URI). Then according to the URI, call the handler mapper (HandlerMapping)
    3. DispatcherServlet generates handler object and handler interceptor according to the obtained Handler, and returns it to DispatcherServlet
    4. DispatcherServlet calls the handler (Handler) through the handler adapter (HandlerAdapter)
    5. Processor (Controller) execution
    6. When done, returns a ModelAndView object
    7. HandlerAdapter returns ModelAndView to DispatcherServlet
    8. DispatcherServlet passes ModelAndView to ViewReslover view resolver
    9. ViewReslover returns the corresponding View after parsing
    10. DispatcherServlet renders the View (that is, fills the model data into the view)
    11. DispatcherServlet responds the rendered view to the user

The difference between injection by constructor and injection by setter method

  1. Injection via setter method:

    <bean id=BEAN_ID class=CLASS_PATH>
    <property name=PROPERTY_NAME value=PROPERTY_VALUE>
    </bean>
  2. Injection via constructor:

    <bean id=BEAN_ID class=CLASS_PATH>
    <!-- 按照索引匹配注入-->
    <constructor-arg index=ARG_INDEX value=ARG_VALUE>
    <!-- 按类型匹配注入-->
       <constructor-arg type=ARG_TYPE value=ARG_VALUE>
    </bean>

Guess you like

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