Answer the question
In order to leave comments, you need to log in
How to pass parameter to fragment?
Good afternoon, It is
necessary to pass a parameter to it when embedding a fragment. The Thymeleaf template engine is used, the application itself is based on Spring (if it matters).
Fragment initiation code
<html th:fragment="navbar (template, menu, head)" xmlns:th="http://www.thymeleaf.org">
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/NavBar :: navbar (~{::body},${param.room},~{::head})}">>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/NavBar :: navbar (~{::body},'Параметр',~{::head})}">>
Answer the question
In order to leave comments, you need to log in
You can try to use preprocessing :
or remove this parameter and just use it ${param.room}
in the included fragment.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question