功能分页

运行环境 springMvc + JPA + jsp
1 前台请求数据
    1.1 ajax 与jquery请求数据 确定url
    1.2 确定分页需求 page 和size
             function initPageList(num){
          $.ajax({
			type: 'get',
	            url: "${base}/url", 
	            data:{
	            	"page":num,
	            	"size":10
	            },
	            //data: $('#customerSearch').serialize(),
	            dataType:'json',
		        success: function(ajaxData){

                        }


2 后台处理数据 获取要得到的数据
        使用JPA 自带分页
        @Autowired
	Repository repository;
    	@RequestMapping(value = "search/instance", method=RequestMethod.GET)
	@ResponseBody
	public Page<T> getInstance(@RequestParam(value = "page", defaultValue = "1") Integer page,
	        @RequestParam(value = "size", defaultValue = "10") Integer size) {
	    Pageable pageable = new PageRequest(page, size);
	    Page<T> pb = repository.findAll(pageable);
	    return pb;
	}

3 前台分页插件处理
使用前台插件 可参考 http://www.jq22.com/jquery-info1025
接收数据后怎么处理 可查插件

猜你喜欢

转载自294368311.iteye.com/blog/2289508