Hej, mam pewne pytanko
Tworzę sobie prostą stronkę z wykorzystaniem Springa i thymeleaf, w thymeleaf stronki mam podzielone w fragmenty (np. header oraz footer)
np to jest fragment z header:
<div class="d-flex" sec:authorize="isAuthenticated()">
<button type="button" class="btn btn-outline-success" data-bs-toggle="modal" data-bs-target="#exampleModal">
<span th:text="${#authentication.name}"></span>
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel" th:text="'Profil użytkownika ' + ${#authentication.name}"></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Liczba napisanych postów: <b >0</b></p>
<p>Liczba napisanych tematów: <b>0</b></p>
<p>Użytkownik od: <b>21.01.1020</b></p>
<p>Aktualna rola: <b>User</b></p>
</div>
<div class="modal-footer align-items-baseline">
<a th:href="@{/auth/gdzies}"><button type="submit" class="btn btn-success">Ustawienia profilu</button></a>
<a th:href="@{/auth/logout}"><button type="button" class="btn btn-success" >Wyloguj się</button></a>
</div>
</div>
</div>
</div>
</div>
i ten header jest wykorzystywany na każdej z podstron np. na stronie głównej:
<nav th:replace="fragments/header :: navigation"></nav>
I pytanko jest takie, jak przekazać jakiś atrybut ale do fragmentu ? tak aby za każdym razem gdy ładują się strony korzystające z fragmentów przekazywało atrybut do tego fragmentu ?
Wybaczcie za masło maślane ale ciężko mi to wytłumaczyć.