@Controller@RequestMapping("/department")public class DepartmentController { @Resource private DepartmentService departmentService; private OutPutTool OutPutTool = new OutPutTool(); @RequestMapping("selectAll") public String select(@RequestParam(value="page",required=false) String page,@RequestParam(value="rows",required=false) String rows,Department department,HttpServletResponse res) throws IOException{ int start=(Integer.parseInt(page)-1)*Integer.parseInt(rows); int pagesize=Integer.parseInt(rows); Mapmap=new HashMap (); map.put("start", start); map.put("size", pagesize); List list=departmentService.selectAll(map); int totl=departmentService.count(); JsonPublic jsonPublic=new JsonPublic(); jsonPublic.setRows(list); jsonPublic.setTotal(totl); OutPutTool.successOutJson(res, jsonPublic); return null; }
easyui datagrid 空间封装的很好,对分页的操作 ,前端会自然地出来 page 和rows值
返回的json符合页面的格式即可
页面这样写即可 ,返回的json格式
{"code":0,"rows":[{"departmentname":"开发部","faxnum":"88888888","id":1,"telephonenum":"88888888"},{"departmentname":"人事部门","faxnum":"88888888","id":2,"telephonenum":"88888888"},{"departmentname":"财务部","faxnum":"88888888","id":3,"telephonenum":"88888888"}],"total":6}
希望此文对大家有所帮助