I'm new to Thymeleaf. It's a simple HelloWorld app in which I want to display the model message returned from controller. It's running successfully but it's not displaying the message returned from controller.
But when the same code is running with a given jsp file it's reading which is a common thing.
WelcomeController
class is
@Controller
public class WelcomeController {
private String pass="Welcome To ThymLeaf";
@RequestMapping(value="/")
public String welcomeUser(Map<String,String> model) {
model.put("message", pass);
return "index";
}
}
My index.html
is
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>ThymLeaf Demo</title>
<link rel="stylesheet" th:href="@{/main.css}" href="../../main.css">
</head>
<body>
<div class="container">
<h1>Spring Boot Using ThymLeaf</h1>
<h2>
<span th:if="${message != null}"
th:text="'Message:' + ${message}">>
</span>
</h2>
</div>
</body>
</html>
It's displaying Spring Boot Using ThymLeaf but not the message attribute because it is coming with a null value but why?