7、数据的分页操作
分页相关的sql
– 第一页数据
select t2.* from (
select t1.,rownum rn from (
select EMPNO,ENAME,JOB,MGR,to_char(HIREDATE,‘yyyy-mm-dd’) as hiredate, SAL,COMM,DEPTNO from emp order by sal
) t1 where rownum<=5) t2 where t2.rn>0;
– 第二页数据
select t2. from (
select t1.,rownum rn from (select * from emp order by sal) t1 where rownum<=10) t2
where t2.rn>5;
– 第三页数据
select t2. from (
select t1.,rownum rn from (select * from emp order by sal) t1 where rownum<=15) t2
where t2.rn>10;
– 第四页数据
select t2. from (
select t1.*,rownum rn from (select * from emp order by sal) t1 where rownum<=20) t2
where t2.rn>15;
8 、Commons-FileUpload文件上传
文件上传的本质就客户端流进入到服务端。
8.1、简介
Commons-FileUpload组件:Commons是Apache开放源代码组织的一个Java子项目,其中的FileUpload是用来处理HTTP文件上传的子项目
Commons-FileUpload组件特点
使用简单:可以方便地嵌入到JSP文件中,编写少量代码即可完成文件的上传功能能够全程控制上传内容
能够对上传文件的大小、类型进行控制
获取Commons-FileUpload组件的方式:http://commons.apache.org/fileupload下载Commons-FileUpload组件
Commons-FileUpload组件类库:commons-fileupload-1.2.2.jar Commons-FileUpload组件的API文档: apidocs
http://commons.apache.org/io下载Commons-IO组件
Commons-IO组件类库:commons-io-2.4.jar
Commons-IO组件的API文档: commons-io-2.4\docs
8.2、怎么玩
先搞个表单
通过流的方式获取数据
添加jar包:
commons-fileupload-1.4.jar commons-io-2.11.0.jar
ServletUpload类
8.3、相关api介绍
9 、文件下载
文件下载的本质其实也是流的操作。服务端进入到客户端。
客户端响应对象的默认设置:告诉浏览器,我的输出是一个下载的操作。
response.setHeader(“ContentDisposition”,“attachment;filename=”+fileNameView);
项目重构:添加如下功能