## 控制器定義
在Controller中返回分頁對象Page變量名為`page`,下面代碼為字典列表實例!
```java
public String index(Model model, Dict dict){
// 創建匹配器,進行動態查詢匹配
ExampleMatcher matcher = ExampleMatcher.matching().
withMatcher("title", match -> match.contains());
// 獲取字典列表
Example<Dict> example = Example.of(dict, matcher);
Page<Dict> list = dictService.getPageList(example);
// 封裝數據
model.addAttribute("list", list.getContent());
model.addAttribute("page", list);
return "/system/dict/index";
}
```
## service定義
在業務層中可通過PageSort創建一個分頁請求對象,也可自行創建分頁請求對象,下面代碼為字典業務層實例!
```
public Page<Dict> getPageList(Example<Dict> example) {
// 創建分頁對象
PageRequest page = PageSort.pageRequest();
return dictRepository.findAll(example, page);
}
```
## 視圖模板定義
```html
<div th:replace="/common/fragment :: page"></div>
```