A template engine processes templates to generate rendered web views. In a Spring MVC application, a controller returns a logical view name, and the selected library resolves that name to a template. section 1.3.1
Connect a template library to a Spring Boot web application:
- Choose a library and add its Spring Boot starter dependency to the build. section 2.5
- Place templates under /src/main/resources/templates in a Maven or Gradle project. section 1.3.1 section 2.5
- Let Spring Boot detect the dependency and automatically configure the components needed to serve controller views. section 2.5
- Replace the dependency and rewrite templates in the chosen language when switching libraries. section 2.5
Resolve a home page
A controller mapped to GET / can return "home". With Thymeleaf available, Spring resolves that logical name to /templates/home.html. The equivalent setup can use Mustache or another supported library, but the template syntax must change. section 1.3.1 section 2.5
Listing 1.4 The home page controller
package tacos;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller #1
public class HomeController {
@GetMapping("/") #2
public String home() {
return "home"; #3
}
}
Inspect the controller annotations, route mapping, and logical view name that connect a web request to a template. section 1.3.1




