O instrutor ilustra o funcionamento do SpringFramework com @RequestBody, em seguida faz com que a rota retorne um template.
Ele remove a anotação @RequestBody, retorna o nome do template e cria o template com o nome index.html na pasta templates.
Não funcionou, então ele instalou o thymeleaf, daí funcionou. No meu caso mesmo após instalar o thymeleaf, ainda não funciona.
================================================
listavip.Configuration
@SpringBootApplication
public class Configuration {
public static void main(String[] args) {
SpringApplication.run(Configuration.class, args);
}
}
listavip.HomeController
@Controller
public class HomeController {
@RequestMapping("/")
public String ola() {
return "index";
}
}
src/main/resources/templates/index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>ListaVIP</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<div class="container">
<div class="jumbotron" align="center" style="margin-top: 50px;">
<h1>Seja bem vindo ao ListaVIPs</h1>
<div align="center">
<a href="listavip" class="btn btn-lg btn-primary">Clique aqui para ver a lista de convidados</a>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
</html>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.gabrieelmoura.listavip</groupId>
<artifactId>listavip</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
</dependencies>
</project>
Resposta retornada:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Feb 12 19:13:48 BRST 2018
There was an unexpected error (type=Not Found, status=404).
No message available