The Spring framework is an open source Java platform that provides a comprehensive infrastructure for developing durable Java applications easily and quickly. After completing the basics, Java class participants will be introduced to the framework, and I’ll give you a brief explanation of how the Spring framework works.
Spring is a multi-tier J2EE application framework that, at its core, provides a new mechanism for managing business objects and their dependencies. It is a container framework for creating beans, maintaining the relationships between beans, managing the Web layer, persistence layer, business layer, etc., configuring the components of each layer and maintaining the relationships of each layer.
Key features of Spring
1) IOC(Inversion of control) or DI (dependency injection) : clearly define the interface of components, independently develop each component, and then assemble and run according to the dependency of components; Give the right to create and manage objects to the Spring container. Spring is a light-weight Container with a Bean Factory at its core to build the M(Model) we need to keep the software components that work together loosely coupled, reducing the complexity of business object replacement, Improved decoupling between components.
2) AOP(aspect oriented programming) : a technique for adding functionality to programs dynamically and uniformly without modifying source code through precompilation and runtime dynamic proxy implementations. That is, system-level services are decoupled from code. For example, separating logging, performance statistics, security controls, transaction handling, exception handling, and so on from business logic code allows you to separate functionality that is spread across your application into reusable components.
How Spring works
SpringMVC asks all requests to be sent to a DispatcherServlet, which delegates the actual processing of the request to other modules in the application system.
2. DispatcherServlet queries one or more HandlerMapping to find the Controller handling the request.
3, DispatcherServlet please request to submit to the target Controller.
4. The Controller will return a ModelAndView after business logic processing.
Dispathcher queries one or more ViewResolver view parsers to find the view object specified by the ModelAndView object.
The view object is responsible for rendering back to the client.
Spring helps you solve problems with the simplest possible solution and is a great addition to the daily work of Java programmers. Most commonly used Java composite frameworks (SSH, SSM) rely on Spring, so we must learn it well.