Detailed description of the working principle and function of Spring in JSP, jspspring
How Spring works in JSP and its Functions
1. springmvc requests all requests to be submitted to DispatcherServlet. It will entrust other modules of the application system to handle the requests in real time.
2. The DispatcherServlet queries one or more HandlerMapping and finds the Controller that processes the request.
3. Submit the DispatcherServlet request to the target Controller.
4. After the Controller processes the business logic, a ModelAndView is returned.
5. The Dispathcher queries one or more ViewResolver view Resolvers and finds the view object specified by the ModelAndView object.
6. view objects are rendered and returned to the client.
Why use Spring:
AOP allows developers to create non-behavioral concerns, known as cross-cutting concerns, and insert them into application code. With AOP, public services (such as logs, persistence, and transactions) can be decomposed into aspects and applied to domain objects without increasing the complexity of the Object Model of domain objects.
IOC allows you to create an application environment that can construct objects and then pass their collaboration objects to these objects. As the word inversion indicates, IOC is like the opposite JNDI. No abstract factory, service locator, singleton, and direct construction are used. Each object is constructed with its collaborative object. Therefore, collaborator is managed by containers ).
Even an AOP framework, Spring is also an IOC container. The best thing about Spring is that it helps you replace objects. With Spring, you only need to add dependencies (collaboration objects) with the JavaBean attribute and configuration file ). Then, you can easily replace a collaboration object with similar interfaces when needed.
The Spring framework is a layered architecture consisting of seven well-defined modules. The Spring module is built on the core container. The core container defines how to create, configure, and manage beans, as shown in figure 1.
Each module (or component) that makes up the Spring framework can exist independently or be implemented together with one or more modules. The functions of each module are as follows:
Core container: the Core container provides the basic functions of the Spring framework. The main component of the core container is BeanFactory, which is the implementation of the factory mode. BeanFactory uses the control reversal (IOC) mode to separate application configuration and dependency specifications from actual application code.
Spring context: the Spring context is a configuration file that provides context information to the Spring framework. Spring context includes enterprise services, such as JNDI, EJB, email, internationalization, checksum and scheduling.
Spring AOP: With the configuration management feature, the Spring AOP module directly integrates Aspect-oriented programming functions into the Spring framework. Therefore, any objects managed by the Spring framework can easily support AOP. The Spring AOP module provides transaction management services for objects in Spring-based applications. By using Spring AOP, You can integrate declarative transaction management into applications without relying on EJB components.
Spring DAO: The JDBCDAO abstraction layer provides a meaningful exception hierarchy for managing Exception Handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the number of Exception Code to be written (for example, opening and closing connections ). SpringDAO JDBC-oriented exceptions follow the common DAO exception hierarchy.
Spring ORM: The Spring framework inserts several ORM frameworks to provide ORM Object Relational tools, including JDO, Hibernate, and iBatis SQL Map. All of these comply with the general transactions and DAO exception hierarchies of Spring.
Spring Web module: The Web context module is built on the application context module, providing context for Web-based applications. Therefore, the Spring framework supports integration with Jakarta Struts. The Web module also simplifies processing multiple requests and Binding Request Parameters to domain objects.
Spring MVC framework: the MVC Framework is a full-featured MVC implementation for Building Web applications. Through the policy interface, the MVC framework becomes highly configurable. MVC supports a large number of view technologies, including JSP, Velocity, Tiles, iText, and POI.
The functions of the spring framework can be used on any J2EE server. Most of the functions are also applicable to unmanaged environments. Spring supports reusable services and data access objects that are not bound to a specific J2EE service. There is no doubt that such objects can be reused between different J2EE environments (Web or EJB), independent applications, and test environments.
The above is an explanation of the working principles and functions of Spring in JSP. If you have any questions, please leave a message or go to the community on this site for discussion. Thank you for reading this article and hope to help you. Thank you for your support for this site!