后端分页实例

废话不多说,先看效果图!

直接上代码:

前端页面

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
 




 
分页测试
 





 
 




 


 

    

控制层:

package com.hgs.amusicweb.controller;
 
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletResponse;
 
import net.sf.json.JSONArray;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
 
import com.hgs.amusicweb.biz.SingerBiz;
import com.hgs.amusicweb.pojo.SingerPojo;
 
//歌手页面
@Controller
@RequestMapping("/SingerController")
public class SingerController {
    @Autowired
    private SingerBiz singerBiz;
     
    @RequestMapping(value = "/getInfo")
    public void inborrowInfo(,HttpServletResponse response)
            throws IOException {
        //查询总记录数
        response.getWriter().print(singerBiz.queryCount());
    }
@RequestMapping(value = "/getInfo222")
    public void inborrowInfo(Integer page,Integer size,HttpServletResponse response)
            throws IOException {
        if(page!=null&&size!=null){
            //查询当前页记录数据
            List querySingerListLimit = singerBiz.querySingerListLimit(page,size);
            JSONArray json = JSONArray.fromObject(querySingerListLimit );
            response.getWriter().print(json);
        }
    }
}
后面的代码就只能靠自己了,哈哈。

你可能感兴趣的:(个人)