получение элементов из бд по id Spring Boot
В моей базе данных есть 3 разных строки с разными элементами:

Как можно вывести по одной строке на разные части страницы? Попробовал через th:if, но на странице отображается некорректно. То есть место выделяется под все элементы, но вывовыдится только элемент по id
Пока html выглядит так:
<div class="mySlides w3-display-container w3-center">
<img th:src="@{/img/img1.jpg}" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-text-white w3-padding-32 w3-hide-small">
<div class="square" th:each="home: ${home}">
<span th:if="${home.id == 1}">
<h3 th:text="${home.title}"></h3>
<p><b th:text="${home.text}"></b></p>
</span>
</div>
</div>
</div>
<div class="mySlides w3-display-container w3-center">
<img th:src="@{/img/img2.jpg}" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-text-white w3-padding-32 w3-hide-small">
<div class="square" th:each="home: ${home}">
<span th:if="${home.id == 2}">
<h3 th:text="${home.title}"></h3>
<p><b th:text="${home.text}"></b></p>
</span>
</div>
</div>
</div>
<div class="mySlides w3-display-container w3-center">
<img th:src="@{/img/img3.jpg}" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-text-white w3-padding-32 w3-hide-small">
<div class="square" th:each="home: ${home}">
<span th:if="${home.id == 3}">
<h3 th:text="${home.title}"></h3>
<p><b th:text="${home.text}"></b></p>
</span>
</div>
</div>
</div>
Контроллер этой странички:
@Controller
public class MainController {
@Autowired
private HomeRepository homeRepository;
@GetMapping("/")
public String home(Model model) {
Iterable<Home> home = homeRepository.findAll();
model.addAttribute("home", home);
return "index";
}
}

