前端代码实现:
跳转到相应的页面,页与页之间切换
```
<c:forEach begin="5" end="${pages}" var="P">
<li class="${i== currentPage ? 'active': ''}"><a href="?a=look&p=${P}" >${P}</a></li>
</c:forEach>
<a href="?a=look&p=${currentPage+1 > pages ? pages : currentPage+1}" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
``
分页实现后端代码:
当前页码值:
int currentPage = req.getParameter("p") == null ? 1 : Integer.parseInt(req.getParameter("p"));
分页量:
int pageSize = 15;
分页后数据:
List <Student> list = ssi.queryPage(currentPage,pageSize);
总条数:
int total = ssi.queryTotal();
总页数:
int pages = (int) Math.ceil(total*1.0 / pageSize);
MySQL:
复制表里内容
MySQL基础知识点:
(1) 启动服务、登录、退出
① 配置环境变量
② 登录1) cmd> mysql -h主机 -u用户名 -p密码2) cmd>
mysql -h127.0.0.1 -uroot -proot3) cmd> mysql -uroot -p
③ Commands
end with ; or \g.每句话已;或\g结尾
④ Type ‘help;’ or ‘\h’ or ‘?’for help.用
help; 或 \h 寻求帮助
⑤ Type ‘\c’ to clear the current input statement. 用\c
来 清除已输入的语句
⑥ \T 开始记录sql语句及结果 到 文件中 ,\t 结束记录
⑦ \W 显示最近的警告信息,\w不显示警告信息 ⑧
quit、exit、\q 退出MySQL
⑨ \d分隔符: 修改分隔符
⑩ \G 按每行去输出结果
⑪ \r 数据库 主机
:切换某个服务器的某个数据库
⑫ use 数据库名 或者 \u 数据库名:切换数据库
⑬ \s
查看当前服务器信息(字符集、端口号,所在数据库等)
⑭ source 或 . 导入恢复数据库
⑮ \C 字符集 切换客户端字符集
(2) 对数据库的CRUD
① 新建数据库 create database 数据库名 character set 字符集;
②
查看已有的数据库 show databases;
③ 查看建库语句 show create database 库名;
④修改数据库 alter database 原数据库名 character set 字符集;
修改库名
① 删除数据库 drop database 数据库名;
② 使用数据库 use 数据库名;(1) 对表的CRUD
① 数据库的数据类型
- int
- double
- date
- datetime
- timestamp
- char
- varchar
① 查看表结构 desc 表名;
② 查看已有的表 show tables;
③ 查看建表语句 show create table 表名;
④ 删除表 drop table 表名;
⑤1) insert into 表名(列名1,列名2) value(值1,值2);
⑥① 设置字符集
- \C gbk
- set names utf8;
⑦ 修改数据 Update 表名 set 列名1=值1,列名2=值2 条件;
⑧ 删除数据1) delete from 表名 条件;
⑨截断表 truncate table 表名;②
⑩查询数据1) select * from 表名;
数据恢复与备份:
备份① cmd> mysqldump -u用户 -p密码 数据库 > 文件路径
恢复① mysql> use 数据库;② mysql> source 文件路径;