Tiptoeing Into Templates

Learn how to use template libraries in Spring Boot.

We'll cover the following...

Templates

So far, we’ve built a web controller that generates streaming JSON. That will help us get oriented with the reactive web. That’s not all that’s needed to build web services. We often need to serve web pages. Therefore, we should turn to template libraries. When it comes to reactive programming, ThymeleafThymleaf fully supports Reactive Streams.

It also has the bonus feature of being 100% HTML-compliant.

Check out the basic example below:

package com.greglturnquist.hackingspringboot.reactive;
import reactor.core.publisher.Mono;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HomeController {
@GetMapping
Mono<String> home() {
return Mono.just("home");
}
}

There’s not too much to analyze here:

  • The ...