Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

77
Visualizações
Breaking the table by month Thymealeaf

Good afternoon. Prompt as means of Thymealeaf to break the table on months. Now everything is displayed correctly sorted by date. But I need the beginning of each month to be signed with a string.

January.

January data

February

February data. Etc..

Table code

            <table  class="table table-bordered table-hover table-sm table-fit">
            <thead>
            <tr>
                <th>Дата начала по плану</th>
                <th>Должность и подразделение</th>
                <th>Шт.ед.</th>
                <th>Причина</th>
                <th>Дата окончания</th>
                <th>Включение в план</th>
                <th>Статус факт</th>
                <th>Дата смещения плана</th>
                <th>Филиалы</th>
            </tr>
            </thead>
            <tbody>
            <div th:each="d : ${descrirtion}">
                <tr class="table-light">
                    <td th:text="${#dates.format(d.start_date, 'dd.MM.yyyy')}"> </td>
                    <td th:text="${d.position} + ' ' + ${d.subdivision}"></td>
                    <td th:text="${d.staff_unit}"></td>
                    <td th:text="${d.reason}"></td>
                    <td th:text="${#dates.format(d.end_date, 'dd.MM.yyyy')}"> </td>
                    <td th:text="${d.status_onit} ? 'Подтверждено':'Не подтверждено'"></td>
                    <td th:text="${d.status_fact} ? 'Подтверждено':'Не подтверждено'"></td>
                    <td th:text="${#dates.format(d.new_start_date, 'dd.MM.yyyy')}"></td>
                    <td th:text="${d.name}"></td>
                </tr>
            </div>
            </tbody>
        </table>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can add a Map with the key being the month and the value the information for that month in your controller.

@GetMapping
public String page(Model model) {
  Map<String, List<Description>> map = ....
  model.addAttribute("map", map);

  return "index";
}

Then in Thymeleaf, you can iterate on the map:

<div th:each="element : ${map}">
  <div> th:text="${element.key}">Month</div>
  <div th:each="d : ${element.value}">
                <tr class="table-light">
                    <td th:text="${#dates.format(d.start_date, 'dd.MM.yyyy')}"> </td>
                    <td th:text="${d.position} + ' ' + ${d.subdivision}"></td>
                    <td th:text="${d.staff_unit}"></td>
                    <td th:text="${d.reason}"></td>
                    <td th:text="${#dates.format(d.end_date, 'dd.MM.yyyy')}"> </td>
                    <td th:text="${d.status_onit} ? 'Подтверждено':'Не подтверждено'"></td>
                    <td th:text="${d.status_fact} ? 'Подтверждено':'Не подтверждено'"></td>
                    <td th:text="${#dates.format(d.new_start_date, 'dd.MM.yyyy')}"></td>
                    <td th:text="${d.name}"></td>
                </tr>
            </div>
</div>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda