Issue
I'm using Thymeleaf for layouts in my project, but unable to get the page title dynamic.
Layout.jsp
<head th:fragment="headerfragment">
<title th:text="@{page-title}"></title>
<!-- Bootstrap Core CSS -->
<link th:href="@{/resources/css/bootstrap.min.css}" rel="stylesheet"
type="text/css" />
</head>
Page.jsp
<head th:include="layout :: headerfragment"></head>
When the final page is rendered i see title as page-title not the actual text
In my controller I set the page-title attribute
modelMap.addAttribute("page-title", "Home");
I might not be doing it right as i'm new to thymeleaf. Please help me to find out the solution.
Solution
The correct syntax is ${page-title}
so in your example it should be changed to <title th:text="${page-title}"></title>
Answered By - code