备忘录:简单的分页

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" import="java.sql.Connection"
import="java.util.Date" errorPage="" %>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>查看所有</title>

<LINK href=style.css type=text/css rel=stylesheet>
<link rel="stylesheet" type="text/css" href="../css/table.css" />
<script type="text/javascript" src="../script/DelCar.js"></script>

</head>

<body bgcolor=#DCDCDC>
<div style ="width:100px; height:50px;position:absolute; top:20px; left:50px"><button onclick="javascript:history.go(-1)">返回到上一页</button></div>
<div align="center"><a style="font-size:200%">申请列表</a></div>
 <div style="position:relative; top:0px;left:680px;">
         <a style="font-size:70%">关键值:</a>
      <input type="text" size=9 name="databy" > 
      <select Style="font-size:60%" name="selectcheck">
       <option value="cardtype">卡类</option>
       <option value="carnum">车牌号</option>
       <option value="applyname">用户姓名</option>
       <option value="ghxh">账号/工号</option>
      </select>
         <button type="button" onclick=window.navigate("./abytest.jsp?name="+selectcheck.value+"&dataname="+databy.value+"") target="carFrame">查看</button>
        </div>

<hr>
<div style="height:10px"></div>


<table  class="tabletop" align="center" bordercolor="#DCDCDC" cellpadding="0" cellspacing="0">

<tr bgcolor="999999">

<Th id="tdl">申请流水号</th>

<th id="tdl" width="133">申请人</th>

<th id="tdl" width="133">申请类别</th>

<th id="tdl" width="133">申请人工号</th>

<th id="tdl" width="133">车辆所有人</th>

<th width="133">操作</th>
</tr>

<%

 //载入驱动程序类别

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection conn=DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=XXX-PC;uid=sa;pwd=admin419;Database=car;");
          

//建立数据库链接,jspdata为ODBC数据源名称

//建立Statement对象

Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

String sql="select * from tab_car";


//建立ResultSet(结果集)对象,并执行SQL语句

ResultSet rs = stmt.executeQuery(sql);

boolean a = rs.next();
if(a==false){
 System.out.println("wrong");
 rs.close();
   stmt.close();
   conn.close();
   return;
}else{
 System.out.println("true");
}
//一页显示的记录数

  int intPageSize;

//记录总数

  int intRowCount;

//总页数

  int intPageCount;

 //待显示页码

  int intPage;

  String  strPage;

  int i;

  //设置一页显示的记录数

 intPageSize =10;

//取得待显示页码

strPage = request.getParameter("page");

//表明在QueryString中没有page这一个参数,此时显示第一页数据

if(strPage==null){

  intPage = 1;

  } else{

//将字符串转换成整型

intPage = java.lang.Integer.parseInt(strPage);

}

if(intPage< 1){

intPage = 1;

}

//获取记录总数

rs.last();

intRowCount = rs.getRow();

//记算总页数

intPageCount = (intRowCount+intPageSize-1) / intPageSize;

//调整待显示的页码

if(intPage >intPageCount) intPage = intPageCount;

if(intPageCount >0){

//将记录指针定位到待显示页的第一条记录上

rs.absolute((intPage-1) * intPageSize+1);

//显示数据

}

i = 0;

while(i< intPageSize && !rs.isAfterLast()){%>

<tr bgcolor="#f8f8f8" class=time>
<%String idl = rs.getString("id");
  String carownerl=rs.getString("carowner");
  String applyghl=rs.getString("applygh");
  String applynamel=rs.getString("applyname");
  String cardtypel=rs.getString("cardtype");
  String applyidl=rs.getString("applyid");
 
  %>
<td id="td1100"><%=applyidl%></td>

<td id="td1100"><%=applynamel%></td>

<td id="td1100"><%=cardtypel%></td>

<td id="td1100"><%=applyghl%></td>

<td id="td1100"><%=carownerl%></td>

<td id="td1000">
 <input type='button' value="详情" onclick="window.open('QueryCarapp.jsp?applyid=<%=applyidl%>')">
 <input type='button' value="删除" onclick="del(<%=applyidl%>)"  >
 </td>


</tr>

  <%rs.next();

   i++;

}   rs.close();

   stmt.close();

   conn.close();%>

</table><p align="center">

 共<%=intRowCount%>个记录,分<%=intPageCount%>页显示,当前页是:第<%=intPageCount%>页

<%for(int j=1;j<=intPageCount;j++)

{out.print("&nbsp;&nbsp;<a href='atest.jsp?page="+j+"'>"+j+"</a>");

}%>

</body>

</html>

 

效果图:

 

在Python 3.8中使用Flask框架创建一个简单备忘录应用程序可以分为几个步骤: 1. **安装依赖**: 首先,确保你已经安装了Python和pip(Python包管理器)。然后通过命令行安装Flask和其他必要的库,如SQLite数据库(用于存储数据): ``` pip install Flask flask_sqlalchemy ``` 2. **创建基本结构**: 创建一个名为`app.py`的文件,开始编写基础的Flask应用: ```python from flask import Flask, request, render_template, redirect, url_for from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///notes.db' db = SQLAlchemy(app) class Note(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), nullable=False) content = db.Column(db.Text) # 初始化数据库连接 db.create_all() ``` 3. **路由设置**: 定义一些基本的路由,比如主页显示所有笔记、添加新笔记、编辑和删除笔记等: ```python @app.route('/') def index(): notes = Note.query.all() return render_template('index.html', notes=notes) @app.route('/add_note', methods=['POST']) def add_note(): title = request.form.get('title') content = request.form.get('content') new_note = Note(title=title, content=content) db.session.add(new_note) db.session.commit() return redirect(url_for('index')) # 添加其他需要的路由函数... ``` 4. **模板设计**: 使用HTML和 Jinja2 模板语言创建视图模板。例如,`templates/index.html` 可能会像这样: ```html <h1>My Notes</h1> {% for note in notes %} <div> <h2>{{note.title}}</h2> <p>{{note.content}}</p> <form action="{{url_for('edit_note', note_id=note.id)}}" method="post"> <input type="hidden" name="_method" value="PUT"> <button>Edit</button> <button>Delete</button> </form> </div> {% endfor %} ``` 5. **错误处理**: 考虑到可能的错误情况,添加适当的异常处理和提交失败时的提示。 6. **运行应用**: 最后,在`app.py`文件底部添加启动应用的代码: ```python if __name__ == '__main__': app.run(debug=True) ``` 这只是一个基础示例,实际项目中可能还需要考虑用户认证、分页、前端样式等问题。运行这个脚本后,你可以访问 `http://localhost:5000/` 来查看和操作备忘录
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值