So I just started working with Thymeleaf and Im not sure exactly how to use this with the html tags. I searched for documentation but I couldn't find anything about this specific issue. It seems so simple but i'm having trouble displaying a h1 html tag that has a variable from my controller in it.
So I Have my basic controller which looks like this:
@SpringBootApplication
@Controller
public class HomeController {
@RequestMapping("/")
public String index(Model model, @RequestParam(value="name", required=false, defaultValue="Human") String name) {
model.addAttribute("name", name);
return "home/index.html";
}
}
and I have my html that looks like this:
<!DOCTYPE html>
<html lang="en">
<head th:replace="fragments::header"></head>
<body>
<h1 th:text="Hello + ${name}"> </h1>
<p>Welcome to Spring Boot!</p>
</body>
</html>
when I load my page it looks like "Helloname" with no space between the Hello and the variable name. How can I fix this? And am I using this the correct way?
`. That's the difference between a _text literal_ and a _literal token_. A good syntax summary can be found [here](https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf#standard-expression-syntax). – andrewJames Sep 01 '21 at 23:31