欢迎,在本教程中,我们将解释弹簧启动应用程序中的分页,为此,我们将使用百里香叶。
在继续本教程之前,我们将了解常用术语,例如 Spring Boot、龙目岛、百里香叶和分页简介。
target/classes
1.2.1 龙目岛的特点
特征 | 详 |
---|---|
val | 局部变量声明为final |
var | 可变局部变量 |
@Slf4J | 创建 SLF4J 记录器 |
@Cleanup | 将调用块中的资源close() finally |
@Getter | 为所有属性创建 getter 方法 |
@Setter | 为所有非最终属性创建二传手 |
@EqualsAndHashCode |
|
@ToString |
|
@NoArgsConstructor |
|
@RequiredArgsContructor |
|
@AllArgsConstructor |
|
@Data |
|
@Builder |
|
@Value |
|
spring-boot-starter-thymeleaf
pom.xml
xmlns:th="https://thymeleaf.org"
PagingAndSortingRepository
这是实现本教程的系统指南,但在进一步讨论之前,我假设您了解 Spring 启动基础知识。
从本教程开始,我们希望您目前在他们最喜欢的选择 IDE 中安装了龙目岛插件。如果有人需要在IntelliJ IDE上完成龙目岛安装,请观看此视频。要在 Eclipse IDE 上进行安装,请观看此视频。
我们正在使用 Eclipse Kepler SR2、JDK 8 和 Maven。如果您对应该在哪里创建相应的文件或文件夹感到困惑,让我们回顾一下 Spring 引导应用程序的项目结构。
图1:项目结构
让我们开始构建应用程序!
以下是开发应用程序所涉及的步骤。
在这里,我们指定了Spring Boot,Spring Data JPA,Thymeleaf,H2数据库,Faker和Lombok的依赖关系。Maven 将自动解析其他依赖项。更新后的文件将具有以下代码。
绒球.xml
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
< project xmlns = "http://maven.apache.org/POM/4.0.0"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" >
< modelVersion >4.0.0 modelVersion >
< groupId >com.springboot.thymeleaf.pagination groupId >
< artifactId >SpringbootThymeleafPaginationV2 artifactId >
< version >0.0.1-SNAPSHOT version >
< name >Springboot thymeleaf pagination tutorial name >
< description >A springboot tutorial to show the pagination in thymeleaf description >
< parent >
< groupId >org.springframework.boot groupId >
< artifactId >spring-boot-starter-parent artifactId >
< version >2.3.4.RELEASE version >
parent >
< properties >
< java.version >1.8 java.version >
properties >
< dependencies >
< dependency >
< groupId >org.springframework.boot groupId >
< artifactId >spring-boot-starter-web artifactId >
dependency >
< dependency >
< groupId >org.springframework.boot groupId >
< artifactId >spring-boot-starter-data-jpa artifactId >
dependency >
< dependency >
< groupId >org.springframework.boot groupId >
< artifactId >spring-boot-starter-thymeleaf artifactId >
dependency >
< dependency >
< groupId >com.h2database groupId >
< artifactId >h2 artifactId >
< scope >runtime scope >
dependency >
< dependency >
< groupId >org.projectlombok groupId >
< artifactId >lombok artifactId >
< scope >provided scope >
dependency >
< dependency >
< groupId >com.github.javafaker groupId >
< artifactId >javafaker artifactId >
< version >1.0.2 version >
dependency >
dependencies >
< build >
< plugins >
< plugin >
< groupId >org.springframework.boot groupId >
< artifactId >spring-boot-maven-plugin artifactId >
plugin >
plugins >
build >
project >
|
在 location: 创建一个新的属性文件,并向其添加以下代码。SpringbootThymeleafPaginationV2/src/main/resources/
应用程序属性
01
02
03
04
05
06
07
08
09
10
11
12
13
14
|
server.port=10091
spring.application.name=springboot-thymeleaf-pagination-v2
# h2 database settings
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
# db-creation settings
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.show_sql=true
## browser url for h2 console - http://localhost:10091/h2-console
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
|
让我们编写此应用程序中涉及的所有 java 类。
3.3.1 实现/主类
将以下代码添加到主类,以便从 main 方法启动应用程序。永远记住,Spring 引导应用程序的入口点是包含注释和静态 main 方法的类。@SpringBootApplication
春靴百里香叶分页.java
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
|
package com.springboot.thymeleaf.pagination.v2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
// Causes Lombok to generate a logger field.
@Slf4j
// Serves two purposes i.e. configuration and bootstrapping.
@SpringBootApplication
public class SpringbootThymeleafPagination {
public static void main(String[] args) {
SpringApplication.run(SpringbootThymeleafPagination. class , args);
log.info( "Springboot Pagination with Thymeleaf application is started successfully ." );
}
}
|
3.3.2 模型类
将以下代码添加到模型类中。Resident
居民.java
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package com.springboot.thymeleaf.pagination.v2.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;
import javax.persistence.*;
import java.time.LocalDate;
@Entity
@Table (name = "resident" )
// Causes Lombok to generate toString(), equals(), hashCode(), getter() & setter(), and Required arguments constructor in one go.
@Data
// Causes Lombok to implement the Builder design pattern for the Pojo class.
// Usage can be seen in DefaultResidentsLoader.java -> createNewResident() method.
@Builder
// Causes Lombok to generate a constructor with no parameters.
@NoArgsConstructor
// Causes Lombok to generate a constructor with 1 parameter for each field in your class.
@AllArgsConstructor
@Component
public class Resident {
@Id
@GeneratedValue (strategy = GenerationType.AUTO)
int id;
@Column (name = "full_name" , nullable = false )
String fullName;
@Column (name = "age" , nullable = false )
int age;
@Column (name = "gender" , nullable = false )
String gender;
@Column (name = "phone_number" , unique = true )
String phoneNumber;
@Column (name = "email_address" , nullable = false , unique = true )
String emailAddress;
@Column (name = "date_of_birth" , nullable = false )
LocalDate dateOfBirth;
@Column (name = "home_address" )
String homeAddress;
@Column (name = "nationality" )
String nationality;
@Column (name = "first_language" )
String firstLanguage;
}
|
3.3.3 配置类
将以下代码添加到将返回该对象的 Bean 对象的 Bean 类中。此对象的用法可以在 theclass 中看到,该类用于在应用程序启动时将虚拟数据加载到数据库中。faker
DefaultResidentsLoader.java
豆子配置.java
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
|
package com.springboot.thymeleaf.pagination.v2.configuration;
import com.github.javafaker.Faker;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Locale;
@Configuration
public class BeanConfiguration {
@Bean
public Faker faker() {
return new Faker( new Locale( "en-US" ));
}
}
|
3.3.4 数据访问对象接口
将以下代码添加到扩展接口的接口中。PagingAndSortingRepository
居民存储库.java
01
02
03
04
05
06
07
08
09
10
|
package com.springboot.thymeleaf.pagination.v2.repository;
import com.springboot.thymeleaf.pagination.v2.model.Resident;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ResidentRepository extends PagingAndSortingRepository
}
|
3.3.5 服务类
将以下代码添加到服务类中,我们将在其中调用 DAO 接口方法将数据保存到数据库中,并从数据库中获取数据。
居民服务.java
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package com.springboot.thymeleaf.pagination.v2.service;
import com.springboot.thymeleaf.pagination.v2.model.Resident;
import com.springboot.thymeleaf.pagination.v2.repository.ResidentRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
// Causes Lombok to generate a logger field.
@Slf4j
@Service
public class ResidentService {
@Autowired
private ResidentRepository repository;
public void save( final Resident resident) {
repository.save(resident);
}
public long getResidentsCount() {
log.info( "Finding the total count of residents from the dB." );
return repository.count();
}
public Page getPaginatedResidents( final int pageNumber, final int pageSize) {
log.info( "Fetching the paginated residents from the dB." );
final Pageable pageable = PageRequest.of(pageNumber - 1 , pageSize);
return repository.findAll(pageable);
}
}
|
3.3.6 引导类
将以下代码添加到引导类,以便在应用程序启动时将虚拟数据保存到数据库中。这些数据将保存在 H2 数据库中。
默认居民加载器.java
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
package com.springboot.thymeleaf.pagination.v2.bootstrap;
import com.github.javafaker.Faker;
import com.springboot.thymeleaf.pagination.v2.model.Resident;
import com.springboot.thymeleaf.pagination.v2.service.ResidentService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.Random;
// Causes Lombok to generate a logger field.
@Slf4j
// Causes Lombok to generate a constructor with 1 parameter for each field that requires special handling.
@RequiredArgsConstructor
@Component
public class DefaultResidentsLoader implements CommandLineRunner {
private static final String[] GENDER = { "Male" , "Female" , "Transgender" , "Not to specify" };
private static final Random RANDOM = new Random();
private final ResidentService service;
private final Faker faker;
@Override
public void run(String... args) throws Exception {
loadResidentsData();
}
private void loadResidentsData() {
if (service.getResidentsCount() == 0 ) {
for ( int x = 0 ; x < 100 ; x++) {
service.save(createNewResident());
}
log.info( "Default residents are successfully saved in the database." );
} else {
log.info( "Default residents are already present in the database." );
}
}
private Resident createNewResident() {
final String firstName = faker.name().firstName();
final String lastName = faker.name().lastName();
final String emailAddress = firstName.toLowerCase() + "." + lastName.toLowerCase() + "@company.com" ;
final LocalDate birthdate = faker.date().birthday( 25 , 58 ).toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
final int age = Period.between(birthdate, LocalDate.now()).getYears();
final String gender = GENDER[RANDOM.nextInt(GENDER.length)];
return Resident.builder()
.fullName(firstName + " " + lastName)
.age(age)
.gender(gender)
.phoneNumber(faker.phoneNumber().cellPhone())
.emailAddress(emailAddress)
.dateOfBirth(birthdate)
.homeAddress(faker.address().fullAddress())
.nationality(faker.nation().nationality())
.firstLanguage(faker.nation().language())
.build();
}
}
|
3.3.7 索引控制器类
将以下代码添加到旨在处理传入请求的控制器类中。该类是用注释注释的,该方法将返回应用程序的页面。@Controller
HTTP GET
index
ResidentController.java
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package com.springboot.thymeleaf.pagination.v2.controller;
import com.springboot.thymeleaf.pagination.v2.dto.ResponseDto;
import com.springboot.thymeleaf.pagination.v2.model.Resident;
import com.springboot.thymeleaf.pagination.v2.service.ResidentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.HashMap;
import java.util.Map;
// Causes Lombok to generate a logger field.
@Slf4j
@Controller
public class ResidentController {
private static final int DEFAULT_PAGE_NUMBER = 1 ;
private static final int DEFAULT_PAGE_SIZE = 10 ;
@Autowired
private ResidentService service;
// URL - http://localhost:10091/
@GetMapping (value = "/" )
public String viewIndexPage() {
log.info( "Redirecting the index page to the controller method for fetching the residents in a paginated fashion." );
return "redirect:residents/paginated/" + DEFAULT_PAGE_NUMBER + "/" + DEFAULT_PAGE_SIZE;
}
@GetMapping (value = "/residents/paginated/{page}/{page-size}" )
public String getPaginatedResidents( @PathVariable (name = "page" ) final int pageNumber,
@PathVariable (name = "page-size" ) final int pageSize, final Model model) {
log.info( "Getting the residents in a paginated way for page-number = {} and page-size = {}." , pageNumber, pageSize);
final Page
model.addAttribute( "responseEntity" , createResponseDto(paginatedResidents, pageNumber));
return "index" ;
}
private ResponseDto createResponseDto( final Page final int pageNumber) {
final Map new HashMap<>();
page.put( "currentPage" , pageNumber);
/*
Here we are fetching the total number of records from the Page interface of the Spring itself.
We can also customize this logic based on the total number of elements retrieved from the query.
*/
page.put( "totalPages" , residentPage.getTotalPages());
page.put( "totalElements" , ( int ) residentPage.getTotalElements());
return ResponseDto.create(residentPage.getContent(), page);
}
}
|
我们将创建一个简单的 HTML 页面,该页面将以较小的块(即分页方法)在浏览器上显示居民。在 位置 : 创建一个新的 HTML 文件,并向其添加以下代码。SpringbootThymeleafPaginationV2/src/main/resources/templates/
索引.html
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
< html lang = "en" xmlns:th = "http://www.thymeleaf.org" >
< head >
< meta charset = "UTF-8" >
< title >Index page title >
< link href = "https://examples.javacodegeeks.com/wp-content/litespeed/localres/aHR0cHM6Ly9zdGFja3BhdGguYm9vdHN0cmFwY2RuLmNvbS8=bootstrap/4.5.2/css/bootstrap.min.css" rel = "stylesheet" >
< style type = "text/css" >
th {
text-align: center;
font-weight: bold;
border-top: none !important;
}
th, td {
white-space: nowrap;
}
.mt-20 {
margin-top: 20px;
}
.table-alignment {
margin-left: -200px;
}
style >
head >
< body >
< div class = "container" >
< h3 class = "text-info text-center mt-20" >Pagination Example : Residents h3 >
< table class = "table table-striped table-alignment mt-20 text-center" >
< thead id = "residentsTable" >
< tr >
< th >Id th >
< th >Full name th >
< th >Age th >
< th >Gender th >
< th >Phone Number th >
< th >Email Address th >
< th >Date of Birth th >
< th >Home Address th >
< th >Nationality th >
< th >First Language th >
tr >
thead >
< tbody >
< tr th:each = "resident : ${responseEntity.residents}" >
< td th:text = "${resident.id}" > td >
< td th:text = "${resident.fullName}" > td >
< td th:text = "${resident.age}" > td >
< td th:text = "${resident.gender}" > td >
< td th:text = "${resident.phoneNumber}" > td >
< td th:text = "${resident.emailAddress}" > td >
< td th:text = "${resident.dateOfBirth}" > td >
< td th:text = "${resident.homeAddress}" > td >
< td th:text = "${resident.nationality}" > td >
< td th:text = "${resident.firstLanguage}" > td >
tr >
tbody >
table >
< div class = "row" >
< div th:if="${responseEntity.page['totalPages'] > 1}">
< div >
Total Items: [[${responseEntity.page['totalPages']}]]
div >
< div >
< span th:each = "i: ${#numbers.sequence(1, responseEntity.page['totalPages'])}" >
< a th:href = "@{'/residents/paginated/' + ${i} + '/10'}"
th:if = "${responseEntity.page['currentPage'] != i}" >[[${i}]] a >
< span th:unless = "${responseEntity.page['currentPage'] != i}" >[[${i}]] span >
span >
div >
< div >
< a th:href = "@{'/residents/paginated/' + ${responseEntity.page['currentPage'] + 1} + '/10'}"
th:if = "${responseEntity.page['currentPage'] < responseEntity.page['totalPages']}" >
Next
a >
< span th:unless = "${responseEntity.page['currentPage'] < responseEntity.page['totalPages']}" >Next span >
div >
< div >
< a th:href = "@{'/residents/paginated/' + ${responseEntity.page['totalPages']} + '/10'}"
th:if = "${responseEntity.page['currentPage'] < responseEntity.page['totalPages']}" >
Last
a >
< span th:unless = "${responseEntity.page['currentPage'] < responseEntity.page['totalPages']}" >Last span >
div >
div >
div >
div >
body >
html >
|
要执行应用程序,请右键单击类。SpringbootThymeleafPagination.java
Run As -> Java Application
图 2:运行应用程序
打开您选择的浏览器并点击以下 URL。结果将以分页方式显示(即较小的块),您可以单击页码以根据页码检索结果。
图3:使用百里香叶在春季启动中进行分页
这就是本教程的全部内容,我希望这篇文章能为您提供所需的任何帮助。快乐学习,不要忘记分享!
在本节中,您了解到,
您可以在“下载”部分中将样例应用程序下载为 Eclipse 项目。
这是使用百里香叶进行Spring Boot分页的一个例子。
存储库
- package com.springboot.thymeleaf.pagination.v2.repository;
-
- import com.springboot.thymeleaf.pagination.v2.model.Resident;
- import java.util.List;
- import org.springframework.data.jpa.repository.Query;
- import org.springframework.data.repository.PagingAndSortingRepository;
- import org.springframework.stereotype.Repository;
-
- @Repository
- public interface ResidentRepository extends PagingAndSortingRepository
{ -
- @Query(value = "SELECT * FROM resident AS r WHERE r.id > ?1 ORDER BY r.id ASC LIMIT ?2",
- nativeQuery = true)
- List
fetchAllAscNext(Long id, Long limit); -
- @Query(value = "SELECT * FROM resident AS r WHERE r.id < ?1 ORDER BY r.id DESC LIMIT ?2",
- nativeQuery = true)
- List
fetchAllAscPrevious(Long id, Long limit); -
- @Query(value = "SELECT count(*) FROM resident", nativeQuery = true)
- public Long fetchCount();
-
- @Query(value = "SELECT min(id) FROM resident", nativeQuery = true)
- public Long fetchMinId();
-
- @Query(value = "SELECT max(id) FROM resident", nativeQuery = true)
- public Long fetchMaxId();
- }
控制器
- package com.springboot.thymeleaf.pagination.v2.controller;
-
- import com.springboot.thymeleaf.pagination.v2.model.Resident;
- import com.springboot.thymeleaf.pagination.v2.repository.ResidentRepository;
- import com.springboot.thymeleaf.pagination.v2.service.ResidentService;
- import java.util.Collections;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.GetMapping;
- import java.util.List;
- import org.springframework.web.bind.annotation.RequestParam;
-
- // Causes Lombok to generate a logger field.
- @Slf4j
- @Controller
- public class ResidentController {
-
- private static final int DEFAULT_PAGE_NUMBER = 1;
- private static final int DEFAULT_PAGE_SIZE = 10;
-
- @Autowired
- private ResidentService service;
-
- @Autowired
- private ResidentRepository repository;
-
- @GetMapping(value = "/")
- public String viewIndexPage() {
- log.info("Redirecting the index page to the controller method for fetching the residents in a paginated fashion.");
- return "redirect:residents/paginated/" + DEFAULT_PAGE_NUMBER + "/" + DEFAULT_PAGE_SIZE;
- }
-
- @GetMapping("/residents")
- public String getPaginatedResidents(Model model, @RequestParam(required = false) String keyword, @RequestParam(defaultValue = "next") String dir,
- @RequestParam(defaultValue = "0") Long page,
- @RequestParam(defaultValue = "10") Long size) {
- log.info("Getting the residents in a paginated way for page-number = {} and page-size = {}.", page, size);
- if (dir.equals("next")) {
- List
fetchAllAscNext = repository.fetchAllAscNext(page, size); - model.addAttribute("responseEntity", fetchAllAscNext);
- model.addAttribute("max", fetchAllAscNext.get(fetchAllAscNext.size() - 1).getId());
- model.addAttribute("min", fetchAllAscNext.get(0).getId());
- } else {
- List
fetchAllAscPrevious = repository.fetchAllAscPrevious(page, size); - Collections.reverse(fetchAllAscPrevious);
- model.addAttribute("responseEntity", fetchAllAscPrevious);
- model.addAttribute("max", fetchAllAscPrevious.get(fetchAllAscPrevious.size() - 1).getId());
- model.addAttribute("min", fetchAllAscPrevious.get(0).getId());
- }
- model.addAttribute("fetchCount", repository.fetchCount());
- model.addAttribute("fetchMinId", repository.fetchMinId());
- model.addAttribute("fetchMaxId", repository.fetchMaxId());
- return "index";
- }
-
- }
视图
- html>
- <html lang="en" xmlns:th="http://www.thymeleaf.org">
- <head>
- <meta charset="UTF-8">
- <title>Index pagetitle>
- <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
- <style type="text/css">
- th {
- text-align: center;
- font-weight: bold;
- border-top: none !important;
- }
-
- th, td {
- white-space: nowrap;
- }
-
- .mt-20 {
- margin-top: 20px;
- }
-
- .table-alignment {
- margin-left: -200px;
- }
- style>
- head>
- <body>
-
- <div class="container">
- <h3 class="text-info text-center mt-20">Pagination Example : Residentsh3>
-
- <table class="table table-striped table-alignment mt-20 text-center">
- <thead id="residentsTable">
- <tr>
- <th>Idth>
- <th>Full nameth>
- <th>Ageth>
- <th>Genderth>
- <th>Phone Numberth>
- <th>Email Addressth>
- <th>Date of Birthth>
- <th>Home Addressth>
- <th>Nationalityth>
- <th>First Languageth>
- tr>
- thead>
- <tbody>
- <tr th:each="resident : ${responseEntity}">
- <td th:text="${resident.id}">td>
- <td th:text="${resident.fullName}">td>
- <td th:text="${resident.age}">td>
- <td th:text="${resident.gender}">td>
- <td th:text="${resident.phoneNumber}">td>
- <td th:text="${resident.emailAddress}">td>
- <td th:text="${resident.dateOfBirth}">td>
- <td th:text="${resident.homeAddress}">td>
- <td th:text="${resident.nationality}">td>
- <td th:text="${resident.firstLanguage}">td>
- tr>
- tbody>
- table>
-
-
-
- <div class="row">
- <div>
- <div>
- Total Items: [[${fetchCount}]]
- div>
- <div>
- <a th:if="${min > fetchMinId}"
- th:href="@{'/residents/?page='+${min}+'&size=10&dir=prev'}" >
- Prev
- a>
- <span th:unless="${min > fetchMinId}">Prevspan>
- div>
- <div>
- <a th:if="${max < fetchMaxId}"
- th:href="@{'/residents/?page='+${max}+'&size=10&dir=next'}" >
- Next
- a>
- <span th:unless="${max < fetchMaxId}">Nextspan>
- div>
-
- div>
- div>
- div>
-
- body>
-
- html>