Answer the question
In order to leave comments, you need to log in
How to output a certain number of th:each values - thymeleaf?
Friends, I’m stuck in one place .. I’m trying to display values from the database, but I ran into the fact that it beats all 500 records for me, and I need 5) Moreover, it creates each block again and again, instead of filling places given to him. I throw the code
<section class="page-category-1 page-category-1_left">
<h2 class="page-title" th:text="#{category.politic}"></h2>
<div class="page-category-1__container" th:each="news : ${newses}">
<div class="page-category-1__col">
<div class="page-category-1__big">
<div class="page-category-1__image"><a href="#"><img src="https://ipsumimage.appspot.com/380x260" alt=""></a></div>
<div class="page-category-1__big-title">
<a th:href="${news.getLink()}" th:text="${news.getTitle()}"></a></div>
<ul class="page-category-1__info">
<li th:text="${news.getSource()}"></li>
<li th:text="${news.getDate()}"></li>
</ul>
</div>
</div>
<div class="page-category-1__col">
<div class="page-category-1__small" >
<div class="page-category-1__small-title"><a th:href="${news.getLink()}" th:text="${news.getTitle()}"></a></div>
<ul class="page-category-1__info">
<li th:text="${news.getSource()}"></li>
<li th:text="${news.getDate()}"></li>
</ul>
</div>
<div class="page-category-1__small">
<div class="page-category-1__small-title"><a th:href="${news.getLink()}" th:text="${news.getTitle()}"></a></div>
<ul class="page-category-1__info">
<li th:text="${news.getSource()}"></li>
<li th:text="${news.getDate()}"></li>
</ul>
</div>
<div class="page-category-1__small">
<div class="page-category-1__small-title"><a th:href="${news.getLink()}" th:text="${news.getTitle()}"></a></div>
<ul class="page-category-1__info">
<li th:text="${news.getSource()}"></li>
<li th:text="${news.getDate()}"></li>
</ul>
</div>
<div class="page-category-1__small">
<div class="page-category-1__small-title"><a th:href="${news.getLink()}" th:text="${news.getTitle()}"></a></div>
<ul class="page-category-1__info">
<li th:text="${news.getSource()}"></li>
<li th:text="${news.getDate()}"></li>
</ul>
</div>
</div>
</div>
<div class="page-all"><a href="#">Всі політичні новини України<svg viewBox="0 0 512 512"><use xlink:href="#icon-arrow"></use></svg></a></div>
</section>
Answer the question
In order to leave comments, you need to log in
Hello!
but faced with the fact that it beats all 500 records for me
List<News>
. Moreover, it creates each block again and again, instead of filling in the places displayed for it. I throw the code
th:each="news : ${newses}"
th:href="${news.getLink()}"
th:each="news, iter : ${newses}"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question