Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

thymeleaf-spring-data-dialect

> 编程语言
Open source

Data pagination made easy with thymeleaf and spring data

199 stars0 likes1 views
WebsiteGitHub

About

Data pagination made easy with thymeleaf and spring data

Thymeleaf Spring Data Dialect

Data pagination made easy with thymeleaf and spring data.

This is a dialect for Thymeleaf that provides some attributes to create pagination and sorting elements, bootstrap style, based on Spring Data.

Usage

Maven dependency:

xml

	io.github.jpenren
	thymeleaf-spring-data-dialect
	3.6.0

Add the Spring Data dialect to your existing Thymeleaf template engine:

java
templateEngine.addDialect(new SpringDataDialect());		// This line adds the dialect to Thymeleaf

If using Spring Boot you can add the following line and the ThymeleafAutoConfiguration class will add the dialect to the template engine.

java
    @Bean
    public SpringDataDialect springDataDialect() {
        return new SpringDataDialect();
    }

This will introduce the sd namespace, and the new attribute processors that you to use in your pages: pagination, pagination-sort, pagination-summary, pagination-url, page-object, pagination-qualifier and page-size-selector.

Examples

In your @Controller

java
@RequestMapping("/users")
public String list(ModelMap model, @SortDefault("username") Pageable pageable){
	model.addAttribute("page", userService.find(pageable));
	
	return "users/list";
}

Your html page looks like:

xml

	
		

		  Username
		  First name
		  Last Name
		  
		

	
	
		

		  Username
		  Name
		  Last Name
		  edit
		

	

    
    

Use optional attribute sd:pagination-split to configure the number of links to show.

Pagination with pager:

xml

    

        
        
&laquo;

        
1 (current)

    

Aligned links:

xml

    

        
        
&laquo;

        
1 (current)

    

Compact pager:

xml

Page size selector (default requires your own javascript code, no action associated):

xml
Show  entries

Page size selector (with javascript code implemented):

xml
Show  entries

Page size selector (dropdown):

xml

Multiple tables on the same page:

On your @Controller

java
@RequestMapping("/users")
public String list(ModelMap model, @Qualifier("foo") Pageable first, @Qualifier("bar") Pageable second){
	model.addAttribute("page", userService.find(first));
	model.addAttribute("barPage", userService.find(second));
	
	return "users/list";
}
xml

        
	
	

        
	

By default SpringDataDialect search in the request for the attribute "page" or if one attribute of type org.springframework.data.domain.Page exists. To use another model attribute, use sd:page-object="${attrName}"

To specify the pagination url use sd:pagination-url tag:

xml

    

        
        
&laquo;

        
1 (current)

    

Sort Icons

The generated HTML has the CSS classes sorted, sorted-asc and sorted-desc. This allows you to quite easily add some custom CSS to have sort icons in the table headers.

Example with FontAwesome:

table.table thead .sorted:after{
	display: inline-block;
	font-family: 'FontAwesome';
	opacity: 0.8;
	margin-left: 1em;
}
table.table thead .sorted.sorted-desc:after{
	content: "\f15e";
}
table.table thead .sorted.sorted-asc:after{
	content: "\f15d";
}

Example with Unicode characters:

.sorted-desc::after, .sorted-asc::after {
    float: right;
}

.sorted-desc::after{
    content:"\25BC";
}

.sorted-asc::after{
    content: "\25B2";
}

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Java

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言