您好我想用百里香叶实现与spring mvc app的分页。 一些我如何创建分页,但它只显示前20个对象,之后没有分页(在ui侧禁用)。我使用普通的休眠标准和弹簧数据Pageable对象。
控制器
<label for="countryId" class="col-md-3 col-xs-12 form-control-label text-md-right">Country</label>
<div class="col-md-8 col-xs-12">
<wj-combo-box id="countryId" tabindex="3" formControlName="countryId" class="form-control" [isEditable]="false" [itemsSource]="countryList"
displayMemberPath="countryName" (ngModelChange)="onCountryChangeEvent($event)" selectedValuePath="countryId" [(ngModel)]="countryId"
required></wj-combo-box>
</div>
<wj-combo-box id="cityId" tabindex="4" formControlName="cityId" class="form-control" [isEditable]="false" [itemsSource]="cityList"
displayMemberPath="cityName" selectedValuePath="cityId" [(ngModel)]="cityId" required></wj-combo-box>
Dao实施
@RequestMapping(value = { "/articles.html", "/" }, method = RequestMethod.GET)
public String getAtricles(Model model, Pageable pageable) {
Page<Article> articlePages = articleService.findAll(pageable);
PageWrapper<Article> page = new PageWrapper<Article>(articlePages, "/articles.html");
model.addAttribute("articles", page.getContent());
model.addAttribute("page", page);
return "index";
}
public Page<Article> findAll(Pageable pageable) {
Criteria c = getSession().createCriteria(Article.class);
c.setFirstResult(pageable.getPageNumber());
c.setMaxResults(pageable.getPageSize());
List<Article> result = c.list();
Page<Article> articlePages = new PageImpl<>(result);
return articlePages;
}