package com.handson.book.Server;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.handson.book.bean.BookBean;
import com.handson.book.bo.BookBo;
import com.handson.book.util.NextAndUp;
public class BookServer extends HttpServlet {
static BookBean book = new BookBean();
public BookServer() {
super();
}
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
String funNo = request.getParameter("funNo");
String page = request.getParameter("page");;
List list = null;
BookBo bo = new BookBo();
if("all".equals(funNo)){
list = bo.getAllList('a');
}else if("next".equals(funNo)){
list = bo.getAllList('n');
}else if("up".equals(funNo)){
list = bo.getAllList('u');
}else if("end".equals(funNo)){
list = bo.getAllList('e');
}else if("update".equals(funNo)){
int bookID = Integer.parseInt(request.getParameter("id"));
int pIndex = Integer.parseInt(request.getParameter("page"));
book = bo.getBook(bookID);
request.setAttribute("book", book);
request.setAttribute("pIndex", pIndex);
request.getRequestDispatcher("/update.jsp").forward(request, response);
return;
}else if("sureUpdate".equals(funNo)){
int pIndex = Integer.parseInt(request.getParameter("page"));
this.getBook(request, response);
request.getRequestDispatcher("/BookServer?funNo=num&page="+pIndex).forward(request, response);
return;
}else if("delete".equals(funNo)){
book = bo.getBook(Integer.parseInt(request.getParameter("page")));
bo.deleteBook(book);
request.getRequestDispatcher("/BookServer?funNo=all").forward(request, response);
return;
}else if("deleteAll".equals(funNo)){
String[] str = request.getParameterValues("bk");
for(int i= 0 ; i < str.length; i++){
book = bo.getBook(Integer.parseInt(str[i]));
bo.deleteBook(book);
}
request.getRequestDispatcher("/BookServer?funNo=all").forward(request, response);
return;
}else if("num".equals(funNo)){
int pageInt = Integer.parseInt(page);
NextAndUp.order = pageInt;
NextAndUp.end = pageInt * 2;
NextAndUp.start = (pageInt - 1)*2;
list = bo.getOnlyBook(pageInt);
}
if(page!=null){
request.setAttribute("page", Integer.parseInt(page));
}else{
request.setAttribute("page",NextAndUp.order);
}
int index = 1;
int max = 3;
int pageIndex = 0;
int maxPage = NextAndUp.orderCount;
if(page != null){
pageIndex = Integer.parseInt(page);
}else{
pageIndex = NextAndUp.order;
}
if(pageIndex%10 != 0 && pageIndex/10 == 0 && pageIndex < maxPage){
if(pageIndex < 3 ){
max = 3;
}else{
max = pageIndex + 1;
}
index = 1;
}else{
if(pageIndex < maxPage){
if(pageIndex < pageIndex /10 * 10 + 1){
max = pageIndex + 1;
}else{
max = pageIndex + 1;
}
index = pageIndex / 10 * 10 -1;
}else if(pageIndex >= maxPage){
max = maxPage;
index = maxPage - 2;
}
}
request.setAttribute("index", index);
request.setAttribute("max", max);
request.setAttribute("count", NextAndUp.orderCount); //灏嗘�婚〉鏁版斁鍏ュ埌request涓�
request.setAttribute("list", list);
request.getRequestDispatcher("/MyJsp.jsp").forward(request, response);
}
public void init() throws ServletException {
// Put your code here
}
public void getBook(HttpServletRequest request,HttpServletResponse response){
book.setBookID(Integer.parseInt(request.getParameter("id")));
book.setBookName(request.getParameter("bookName"));
book.setBookImg(request.getParameter("bookUser"));
new BookBo().UpdateBook(book);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
jsp分页,显示上一页,下一页,首页,末页,和数据页“1,2,3,4,……”
共81个文件
jar:16个
tld:16个
bmp:15个
5星 · 超过95%的资源 需积分: 50 351 下载量 123 浏览量
2010-10-11
19:05:08
上传
评论 6
收藏 8.65MB ZIP 举报
温馨提示
jsp 分页显示数据,显示“页数”,“第几页”,“上一页” “下一页” “首页” “尾页”“1,2,3,4,5……”;分页效果和平时所见的分页效果相同,数据库用hibernate链接 “上一页”显示的数据和“1,2,3,4……”想对应,当前页数用不同的样式显示
资源推荐
资源详情
资源评论
收起资源包目录
BookText.zip (81个子文件)
BookText
img
0.bmp 3KB
3.bmp 3KB
14.bmp 3KB
13.bmp 3KB
1.bmp 3KB
4.bmp 3KB
8.bmp 3KB
11.bmp 3KB
都市藏娇.CHM 4.57MB
2.bmp 3KB
5.bmp 3KB
9.bmp 3KB
10.bmp 3KB
12.bmp 3KB
hibernate.cfg.xml 884B
7.bmp 3KB
6.bmp 3KB
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 500B
org.eclipse.jdt.core.prefs 330B
src
com
handson
book
dao
BookDao.java 2KB
bean
BookBean.java 574B
BookBean.hbm.xml 479B
Server
BookServer.java 4KB
UpdateBook.java 1KB
bo
BookBo.java 558B
util
Factory.java 583B
NextAndUp.java 2KB
hibernate.cfg.xml 756B
.project 1KB
WebRoot
META-INF
MANIFEST.MF 39B
WEB-INF
scriptfree.tld 2KB
c-1_0.tld 11KB
fmt-1_0.tld 12KB
fn.tld 7KB
web.xml 1KB
fmt.tld 19KB
x.tld 12KB
Pagination.tld 743B
x-1_0-rt.tld 7KB
fmt-1_0-rt.tld 11KB
x-1_0.tld 7KB
sql.tld 8KB
classes
com
handson
book
dao
BookDao.class 2KB
bean
BookBean.class 979B
BookBean.hbm.xml 479B
Server
BookServer.class 4KB
UpdateBook.class 1KB
bo
BookBo.class 1KB
util
NextAndUp.class 1KB
Factory.class 1KB
hibernate.cfg.xml 756B
sql-1_0.tld 6KB
sql-1_0-rt.tld 5KB
lib
sqljdbc.jar 227KB
cglib-2.1.3.jar 244KB
dom4j-1.6.1.jar 257KB
jta.jar 9KB
mssqlserver.jar 66KB
standard.jar 384KB
msbase.jar 280KB
msutil.jar 58KB
asm.jar 26KB
jstl.jar 20KB
commons-logging.jar 33KB
ehcache-1.2.jar 102KB
asm-attrs.jar 16KB
commons-collections-3.2.jar 558KB
antlr-2.7.6.jar 425KB
hibernate3.jar 1.8MB
c-1_0-rt.tld 11KB
permittedTaglibs.tld 1KB
c.tld 16KB
js
jquery-1.3.2.js 118KB
index.jsp 624B
update.jsp 2KB
MyJsp.jsp 4KB
book.sql 7KB
.mymetadata 297B
.classpath 1KB
.myeclipse
共 81 条
- 1
liqi756856
- 粉丝: 40
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于lua-nginx-module,可以多维度检查和拦截恶意网络请求,具有简单易用、高性能、轻量级的特点
- 一个基于qt开发的包含各种基础图像处理技术的桌面应用,图像处理算法基于halcon,有直接调用halcon脚本和执行halcon
- 【带个人免签支付】宝宝取名源码 易经在线起名网 周易新生儿取名 生辰八字取名系统
- 微信公众号批量下载工具
- 创维8A06机芯 E750A系列 通用主程序 电视刷机 固件升级包 Ver01.01
- LxRunOffline-v3.5.0-11-gfdab71a-msvc.zip
- 惠普Laser Jet Professional P1100(系列)打印机驱动下载
- C#毕业设计基于leap motion和CNN的手语识别系统源代码+数据集+项目文档+演示视频
- 绑定halcon显示控件,可实现ROI交互,用于机器视觉领域.zip
- java连接数据库,jdbc连接数据库,并实现在控制台显示输入书名查询书本
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页