Spring Web Reactive is one of the important new features in Spring Framework 5. It brings in reactive capabilities for web applications.
Spring Web Reactive is based on the same fundamental programming model as Spring MVC. The following table provides a quick comparison of the two frameworks:
. | Spring MVC | Spring Web Reactive |
Use | Traditional web application | Reactive web applications |
Programming Model | @Controller with @RequestMapping | The same as Spring MVC |
Base API | The Servlet API | Reactive HTTP |
Runs on | Servlet Containers | Servlet Containers(>3.1), Netty, and Undertow |
In the subsequent steps, we want to implement a simple use case for Spring Web Reactive.
The following are the important steps involved:
- Creating a project using Spring Initializr
- Creating a Reactive Controller returning an event stream (Flux)
- Creating an HTML view