Spring Web Reactive is one of the most 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:
Parameters | Spring MVC | Spring Web Reactive |
Use | Traditional web application | Reactive web application |
Programming Model | @Controller with @RequestMapping | The same as Spring MVC |
Base API | The servlet API | Reactive HTTP |
Runs on | Servlet containers | Servlet containers(less than 3.1), Netty, and Undertow |
In the subsequent steps, we 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