1. 程式人生 > 其它 >Spring Doc - Web Servlet

Spring Doc - Web Servlet

This part of the documentation covers support for Servlet-stack web applications built on the Servlet API and deployed to Servlet containers.

1. Spring Web MVC

Spring Web MVC is the original web framework built on the Servlet API and has been included in the Spring Framework from the very beginning.Parallel to Spring Web MVC, Spring Framework 5.0 introduced a reactive-stack web framework whose name, “Spring WebFlux”.

DispatcherServlet
Spring MVC, as many other web frameworks, is designed around the front controller pattern where a central Servlet, the DispatcherServlet, provides a shared algorithm for request processing, while actual work is performed by configurable delegate components. This model is flexible and supports diverse workflows.

The DispatcherServlet, as any Servlet, needs to be declared and mapped according to the Servlet specification by using Java configuration or in web.xml. In turn, the DispatcherServlet uses Spring configuration to discover the delegate components it needs for request mapping, view resolution, exception handling, and more.

Filters
the spring-web module provides some useful filters:Form Data, Forwarded Headers, Shallow ETag, CORS.

Annotated Controllers
Spring MVC provides an annotation-based programming model where @Controller and @RestController components use annotations to express request mappings, request input, exception handling, and more. Annotated controllers have flexible method signatures and do not have to extend base classes nor implement specific interfaces.

2. REST Clients

This section describes options for client-side access to REST endpoints.

3. Testing

This section summarizes the options available in spring-test for Spring MVC applications.

4. WebSockets

This part of the reference documentation covers support for Servlet stack, WebSocket messaging that includes raw WebSocket interactions, WebSocket emulation through SockJS, and publish-subscribe messaging through STOMP as a sub-protocol over WebSocket. The WebSocket protocol provides a standardized way to establish a full-duplex, two-way communication channel between client and server over a single TCP connection.

5. Other Web Frameworks

his chapter details Spring’s integration with third-party web frameworks.