spring data jpa实现分页查询功能
生活随笔
收集整理的這篇文章主要介紹了
spring data jpa实现分页查询功能
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
spring data jpa實現(xiàn)分頁查詢功能
HTML代碼部分:
// 收派標(biāo)準(zhǔn)信息表格 $('#grid').datagrid( {iconCls : 'icon-forward',fit : true,border : false,rownumbers : true,striped : true,pageList: [30,50,100],pagination : true,toolbar : toolbar,url : "../../standard_pageQuery.action",idField:'id',columns : columns });Action類:
//收派標(biāo)準(zhǔn)分頁列表查詢 @Action(value="standard_pageQuery",results={@Result(name="success",type="json")}) public String pageQuery(){//調(diào)用業(yè)務(wù)層,查詢數(shù)據(jù)結(jié)果Pageable pageable = new PageRequest(page-1,rows);Page<Standard> pageData = standardService.findPageData(pageable);//返回客戶端數(shù)據(jù)需要total和rowsMap<String,Object> result = new HashMap<String,Object>();result.put("total", pageData.getNumberOfElements());result.put("rows",pageData.getContent());//將map轉(zhuǎn)換為json數(shù)據(jù)返回,使用struts-json-plugin插件ActionContext.getContext().getValueStack().push(result);return SUCCESS; }Service代碼:
@Override public Page<Standard> findPageData(Pageable pageable) {// TODO Auto-generated method stubreturn standardRepository.findAll(pageable); }dao層:
public interface StandardRepository extends JpaRepository<Standard,Integer>{}總結(jié)
以上是生活随笔為你收集整理的spring data jpa实现分页查询功能的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: easyui收派标准客户端表单校验
- 下一篇: spring data jpa实现有条件