Using Spring WebFlux for controller
Controllers are the integration point between models and views in the MVC paradigm. They act like the glue that binds together everything while taking care of business logic execution and routing. The following Maven starter dependency
needs to be added to enable Spring WebFlux:
<dependencies> ... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency> </dependencies>
The preceding dependency
will import the Reactive Streams, Spring, and Netty dependencies to enable successful writing of Servlet
-based web applications using Spring.
Implementation of controllers
The following is the IndexController
that caters the index URL:
@Controller public class IndexController { @GetMapping("/") public String index() { return "redirect:/article"; } }
The index
method is mapped to the URL /
, which will redirect to the /article
URL when...