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]LeetCode825. 适龄的朋友 | Friends Of Appropriate Ages
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ...
- [Swift]LeetCode981. 基于时间的键值存储 | Time Based Key-Value Store
Create a timebased key-value store class TimeMap, that supports two operations. 1. set(string key, s ...
- python-函数参数
1.Python的函数定义非常简单,但灵活度却非常大.除了正常定义的必选参数外,还可以使用默认参数.可变参数和关键字参数,使得函数定义出来的接口,不但能处理复杂的参数,还可以简化调用者的代码 1).位 ...
- Zara带你快速入门WPF(3)---触发器篇
一.前言 使用触发器,可以动态的改变控件的外观,因为一些事件或属性改变了,把鼠标移动到按钮上,按钮就会改变其外观.通常这些必须写在C#代码中,使用WPF也可以使用XAMl实现,而这只会影响UI. 属性 ...
- 免费SSL证书(支持1.0、1.1、1.2)
由于公司要开发微信小程序,而微信小程序的接口需要https协议的,并且要支持TLS1.0.TLS1.1.TLS1.2.如果仅仅是为了开发小程序,安全等级又不用太高,可以选择免费的SSL证书 在这里选择 ...
- asp.net core系列 31 EF管理数据库架构--必备知识 反向工程
一. 反向工程 反向工程是基于数据库架构,生成的实体类和DbContext类代码的过程,对于Visual Studio开发,建议使用PMC.对于其他开发环境,请选择.NET Core CLI工具( ...
- 【Vue笔记】-- 详解vue生命周期
针对于Vue的生命周期进行详细的说明,方面加深对各个方法的引用. 引言: 前几天重新回顾vue官网时,看到vue的生命周期,想着自己用vue开发了快一年了,就总结总结vue知识,再次加深自己对vue的 ...
- SQL数据库连接语句
一般的远程访问的写成这样: Data Source=IP ;Initial Catalog=数据库名 ;UserID= 用户名 ;Password=密码 本地访问的写成这样: Data Source= ...
- Java基础15:深入剖析Java枚举类
更多内容请关注微信公众号[Java技术江湖] 这是一位阿里 Java 工程师的技术小站,作者黄小斜,专注 Java 相关技术:SSM.SpringBoot.MySQL.分布式.中间件.集群.Linux ...
- Config安全控制
1.config server引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <a ...