其他分享
首页 > 其他分享> > 根基id查询不同类别的旅游线路数据、旅游线路分页展示_分页数据展示_代码实现Servlet

根基id查询不同类别的旅游线路数据、旅游线路分页展示_分页数据展示_代码实现Servlet

作者:互联网

根基id查询不同类别的旅游线路数据

分页展示旅游线路数据

 

 

 编码的编写

  客户端代码编写

  服务器端代码编写

    创建了PageBean对象

    

public class PageBean <T>{
private int totalCount;//总记录数
private int totalPage;//总页数
private int currentPage;//当前页码
private int pageSize;//每页显示的条数

private List<T> list;//每页显示的数据集合

public int getTotalCount() {
return totalCount;
}

public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}

public int getTotalPage() {
return totalPage;
}

public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}

public int getCurrentPage() {
return currentPage;
}
    public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}



public int getPageSize() {
return pageSize;
}

public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}

public List<T> getList() {
return list;
}

public void setList(List<T> list) {
this.list = list;
}
}

 

 

旅游线路分页展示_分页数据展示_代码实现Servlet

  后台代码编写

    RouteServlet

    

@WebServlet("/route")
public class RouteServlet extends BaseServlet{
private RouteService service= new RouteServiceImpl();
/**
* 分页查询
* @param req
* @param resp
* @throws ServletException
* @throws IOException
*/
public void pageQuery(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//接受参数
String currentPageStr = req.getParameter("currentPage");
String pageSizeStr = req.getParameter("pageSize");
String cidStr = req.getParameter("cid");
//处理参数
int cid = 0;//类别id
if (cidStr !=null && cidStr.length()>0){
cid = Integer.parseInt(cidStr);
}

//处理参数
int currentPage = 0;//当前页码,如果不传递,则默认为第一页
if (currentPageStr !=null&&currentPageStr.length()>0){
currentPage = Integer.parseInt(currentPageStr);
}else {
currentPage=1;
}

//处理参数
int pageSize = 0;//每页显示条数,如果不传递,默认每页显示5条记录
if (pageSizeStr !=null&&pageSizeStr.length()>0){
pageSize = Integer.parseInt(pageSizeStr);
}else{
pageSize=5;
}

//调用service查询PageBean对象
PageBean<Route> pb = service.pageQuery(cid,currentPage,pageSize);
//将PageBean序列化并返回
writerValue(pb,resp);
}
}

      

    RouteService

    RouteDao

 

标签:分页,pageSize,展示,int,void,private,线路,currentPage,public
来源: https://www.cnblogs.com/ssr1/p/16635477.html