@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
//对List数据分页
req.setAttribute("list", list);
int pageNos;
if (req.getParameter("pageNos") == null
|| Integer.parseInt(req.getParameter("pageNos")) < 1) {
pageNos = 1;
} else {
pageNos = Integer.parseInt(req.getParameter("pageNos"));
}
req.setAttribute("pageNos", pageNos);
int size=list.size();
int countPage = size%4==0? size/4:size/4+1;
// 总页数
req.setAttribute("countPage", countPage);
req.getRequestDispatcher("search.jsp").forward(req, resp);
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>结果</title>
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<% String 查找的参数 = request.getParameter("查找的参数");
%> <form action="search" method="get" enctype="application/x-www-form-urlencoded">
<img src="data:image/logo.jpg" height="40px"/>
<input id="css1" name="查找的参数" value=<%=查找的参数%> maxlength="30">
<span ><input type="submit" id="css2" value="搜索一下"></span> <c:forEach var="li" items="${list}" begin="${(pageNos-1)*4 }" end="${pageNos*4-1}">
<br>
<p>数据 </p> <br/>
</c:forEach> <center>
<c:if test="${pageNos>1 }">
<a href="search?查找的参数=<%=查找的参数%>&pageNos=1" >首页</a>
<a href="search?查找的参数=<%=查找的参数%>&pageNos=${pageNos-1 }">上一页</a>
</c:if>
<c:if test="${pageNos <countPage }">
<a href="search?查找的参数=<%=查找的参数%>&pageNos=${pageNos+1 }">下一页</a>
<a href="search?查找的参数=<%=查找的参数%>&pageNos=${countPage }">末页</a>
</c:if>
</center> <h4 align="center">共${countPage}页
<input type="text" value="${pageNos}" name="pageNos" size="1">页
<input type="submit" value="go"> </h4>
</form>

httpservlet里单纯分页的更多相关文章

  1. winform里dataGridView分页代码,access数据库

    winform里dataGridView分页,默认dataGridView是不分页的和webform里不一样,webform中GridView自带自带了分页. 现在c/s的程序很多时候也需要webfo ...

  2. freemarker里的分页--ftl文件的传值

    在上一篇<freemarker里的分页--ftl文件>中我们讨论了分页的逻辑,在这一篇文章中,我们開始看一下怎样进行ftl的传值 或许你在上一篇文章中已经发现了端倪.是的,不错,我们须要一 ...

  3. Django中html里的分页显示

    分页一(very low) 因为数据量过大,而又想直观便捷的查看数据,进而通过分页显示就可以完成这项工作 app中views.py LIST=[] #全局定义一个LIST for i in range ...

  4. WPF里DataGrid分页控件

    1.主要代码: using System; using System.Collections.ObjectModel; using System.Windows; using System.Windo ...

  5. ssrs 里 表头 分页后显示

    1. 列组,箭头,高级 2.点击行组,静态 3. 设置静态行组 属性

  6. java里自定义分页查询的尝试

    public String list(){ try { LoginUser loginUser = getLoginUser();//获取当前登录用户 if(curpage<=0){ curpa ...

  7. Java项目之查询后分页

    一.Jsp页面: <%@ page language="java" contentType="text/html; charset=UTF-8" page ...

  8. WPF DataGrid分页功能实现代码 修改原作者不能实现的部分

    这两天需要给Datagrid加个分页,查找了一些相关的文章,发现有一个写了一个控件比较好,地址是 http://blog.csdn.net/zdw_wym/article/details/822189 ...

  9. 7.django之自定义分页记录

    只是大概记录下步骤: 1.表结构: class UserProfile(models.Model): ''' 用户表 ''' user = models.OneToOneField(User,verb ...

随机推荐

  1. [Swift]LeetCode951. 翻转等价二叉树 | Flip Equivalent Binary Trees

    For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left a ...

  2. SQLplus下命令输入错误如何删掉重新输入

    如下当我们输入命令出错时想删掉重新输入,按delete或者backspace键无法删除且出现如下情况: SQL> show urerej  ^H^H^H^H^H 可以是使用ctrl+backsp ...

  3. EF实现批量插入

    Z.EntityFramework.BulkInsert EntityFramework 最被人诟病的地方就是它的性能,处理大量数据时的效率.此种条件下,通常会转回使用 ADO.NET 来完成任务.而 ...

  4. ASP.NET Core WebAPI中的分析工具MiniProfiler

    介绍 作为一个开发人员,你知道如何分析自己开发的Api性能么? 在Visual Studio和Azure中, 我们可以使用Application Insight来监控项目.除此之外我们还可以使用一个免 ...

  5. 华为oj之等差数列前n项和

    题目: 等差数列 热度指数:1010 时间限制:1秒 空间限制:32768K 题目描述 功能: 对于等差数列 2,5,8,11,14- 输入: 正整数N >0 输出: 求等差数列前N项和 返回: ...

  6. Android中颜色透明度对应16进制值

    透明度百分比对应的十六进制: (说明:百分比计算出来会有小数,按照常规的四舍五入处理,详情请往下查看) 百分比:0% HEX: 00 百分比:1% HEX: 30 百分比:2% HEX: 50 百分比 ...

  7. 在Mac上使用远程X11应用

    XWindows太老了,历史比Windows和Linux的开发时间都长,以至于很多人每天实际在用,但已经不知道它的存在. XWindows目前是Linux/类Unix系统上的标准显示配置,QT/GTK ...

  8. 【Python3爬虫】第一个Scrapy项目

    Python版本:3.5    IDE:Pycharm 今天跟着网上的教程做了第一个Scrapy项目,遇到了很多问题,花了很多时间终于解决了== 一.Scrapy终端(scrapy shell) Sc ...

  9. JAVA 连等赋值问题

    一.描述 关于 Java 连等赋值,例如a=b=c;我们知道它是从右往左依次赋值的,其结果大致可以拆分为b=c;a=b;,但是当栈中没有持有变量的引用时,则会出现问题,例如: public class ...

  10. Oracle学习笔记二

    多表查询: 笛卡尔积: 实际上是两张表的乘积,但是在实际开发中没有太大意义 格式: select * from 表1,表2 select * from emp; select * from dept; ...