httpservlet里单纯分页
@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里单纯分页的更多相关文章
- winform里dataGridView分页代码,access数据库
winform里dataGridView分页,默认dataGridView是不分页的和webform里不一样,webform中GridView自带自带了分页. 现在c/s的程序很多时候也需要webfo ...
- freemarker里的分页--ftl文件的传值
在上一篇<freemarker里的分页--ftl文件>中我们讨论了分页的逻辑,在这一篇文章中,我们開始看一下怎样进行ftl的传值 或许你在上一篇文章中已经发现了端倪.是的,不错,我们须要一 ...
- Django中html里的分页显示
分页一(very low) 因为数据量过大,而又想直观便捷的查看数据,进而通过分页显示就可以完成这项工作 app中views.py LIST=[] #全局定义一个LIST for i in range ...
- WPF里DataGrid分页控件
1.主要代码: using System; using System.Collections.ObjectModel; using System.Windows; using System.Windo ...
- ssrs 里 表头 分页后显示
1. 列组,箭头,高级 2.点击行组,静态 3. 设置静态行组 属性
- java里自定义分页查询的尝试
public String list(){ try { LoginUser loginUser = getLoginUser();//获取当前登录用户 if(curpage<=0){ curpa ...
- Java项目之查询后分页
一.Jsp页面: <%@ page language="java" contentType="text/html; charset=UTF-8" page ...
- WPF DataGrid分页功能实现代码 修改原作者不能实现的部分
这两天需要给Datagrid加个分页,查找了一些相关的文章,发现有一个写了一个控件比较好,地址是 http://blog.csdn.net/zdw_wym/article/details/822189 ...
- 7.django之自定义分页记录
只是大概记录下步骤: 1.表结构: class UserProfile(models.Model): ''' 用户表 ''' user = models.OneToOneField(User,verb ...
随机推荐
- [Swift]LeetCode990. 等式方程的可满足性 | Satisfiability of Equality Equations
Given an array equations of strings that represent relationships between variables, each string equa ...
- [Swift]LeetCode1005. K 次取反后最大化的数组和 | Maximize Sum Of Array After K Negations
Given an array A of integers, we must modify the array in the following way: we choose an i and repl ...
- python bz2模块
bz2模块提供了使用bzip2算法压缩和解压缩数据一套完整的接口. bz2模块包括: 用于读写压缩文件的open()函数和BZ2File类 用于一次性压缩和解压缩的compress() 和 decom ...
- GenerationType四中类型
https://blog.csdn.net/u011781521/article/details/72210980 JPA提供的四种标准用法为TABLE,SEQUENCE,IDENTITY,AUTO. ...
- BBS论坛(十六)
16.登录功能完成 (1)front/forms.py class SigninForm(BaseForm): telephone = StringField(validators=[Regexp(r ...
- 【Docker】(3)---linux部署Docker、Docker常用命令
linux部署Docker.Docker常用命令 本次部署Linux版本:CentOS 7.4 64位. 说明: 因为Docker是基于Linux 64bit的 所以Docker要求64位的系统且内核 ...
- JAVA数组和集合谁是儿子
Java有哪些数据存储方式? 基本数据类型(1byte3整2小数1字符1布尔)分别是byte,short,int long,flort,double,char,boolean(颜色好喜庆的样子O(∩_ ...
- JS判断客户端是否是iOS或者Android手机移动端(转载)
前言: 上午有一个移动端的项目负责人问我,在ios系统上样式出现问题,因为内核原因,我改来改去,在ios弄好了,但在安卓有问题了,突然想到了一种办法,既然ios是一种机型,安卓是一种机型,可以检测用户 ...
- 由Nginx的DNS缓存导致的访问404
现象 访问某个URL出现404,而且全站都是404.通过日志查看Nginx的规则也正确,请求被代理到指定位置. 排查 最近针对这个站点没有修改过Nginx配置也没有站点升级.所以应该是其他原因.首先P ...
- 前端笔记之JavaScript(四)关于函数、作用域、闭包那点事
一.自定义函数function 函数就是功能.方法的封装.函数能够帮我们封装一段程序代码,这一段代码会具备某一项功能,函数在执行时,封装的这一段代码都会执行一次,实现某种功能.而且,函数可以多次调用. ...