What template engine is in Spring, which is similar to Blade in laravel?
I am new to Spring, I searched templating engines, but have only found Jtwig, although it seems more a set of functions.
I need that like blade, to generate templates with the header, content, footer, include other views, etc. Thanks
1. JMustache is a template engine which can be easily integrated into a Spring Boot application by using the spring-boot-starter-mustache dependency. Pebble contains support for Spring and Spring Boot within its libraries.
Apache FreeMarker™ is a template engine: a Java library to generate text output (HTML web pages, e-mails, configuration files, source code, etc.) based on templates and changing data.
Spring MVC, Struts or Apache Wicket are examples of web frameworks, whereas JSP, Velocity or FreeMarker are examples of template engines.
Try Thymeleaf. It is supposed to be the successor of JSP
(now considered outdated).
See this tutorial on how to integrate it with Spring. Even the Spring team themselves are endorsing Thymeleaf.
To see Thymleaf layouting in action, see this page.
main.html
...
<div th:replace="fragments/footer :: footer">
footer placeholder text to be replaced
</div>
fragments/footer.html
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<div th:fragment="footer">
actual footer text
</div>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With