I\'m new on Thymeleaf template engine, and I\'m making an application with Spring Boot and Spring MVC. I\'m working just with application.properties
for the con
You could do something like this. Let's say you create a page where all other content will be embedded - main.html
. It will look something like this:
Some header
Some footer
Then you want to create some page which will be embedded in your main.html
page - some-page.html
:
${title}
The goal is to replace within
main.html
with the content from some-page.html
. In controller, that will look like this:
@Controller
public class DemoController {
@RequestMapping
public String somePage(Model model) {
// Note that you can easy pass parameters to your "somePage" fragment
model.addAttribute("title", "Woa this works!");
return "main :: mainPage(page='some-page', fragment='somePage')";
}
}
And there you go! Every time when you want to swap content in main.html
, you just change page
and fragment
parameters within string in your controller.