package com.mxx.bookServlet;
import java.io.IOException;
import java.io.PrintWriter;
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.mxx.dao.*;
public class BookServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public BookServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=GBK");
request.setCharacterEncoding("GBK");
int page = 0 ; //当前页数
int pageSize = 5; //显示多少页
int total = 0 ; //一共有多少行数据
int countPages = 0; //共有多少页
String temp = request.getParameter("page");
if(temp == null)
page = 1;
else
page = Integer.parseInt(request.getParameter("page"));
if(page < 1)
page = 1;
//获取集合
List list = new BookDao().getAll(page, pageSize);
//得到总数量
total = new BookDao().CountNum();
//算出共多少页
countPages = (total+pageSize - 1) / pageSize;
request.setAttribute("page", page);
request.setAttribute("pageSize", pageSize);
request.setAttribute("total", total);
request.setAttribute("countPages", countPages);
request.setAttribute("list", list);
request.getRequestDispatcher("MyPage.jsp").forward(request, response);
// PrintWriter out = response.getWriter();
// out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
// out.println("<HTML>");
// out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
// out.println(" <BODY>");
// out.print(" This is ");
// out.print(this.getClass());
// out.println(", using the GET method");
// out.println(" </BODY>");
// out.println("</HTML>");
// out.flush();
// out.close();
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
MVC纯java分页,不含jsp脚本
共28个文件
tld:5个
java:4个
class:4个
3星 · 超过75%的资源 需积分: 4 24 下载量 193 浏览量
2009-12-02
17:55:18
上传
评论
收藏 398KB RAR 举报
温馨提示
实现java分页,不含jsp脚本,使用EL表达式,有首页,上一页,下一页,尾页等连接
资源推荐
资源详情
资源评论
收起资源包目录
纯java分页.rar (28个子文件)
纯java分页
MyJavaPage
.project 1KB
.mymetadata 303B
WebRoot
WEB-INF
struts-tiles.tld 8KB
.struts-config.mex 48B
web.xml 1KB
struts-config.xml 422B
struts-bean.tld 9KB
struts-nested.tld 70KB
struts-html.tld 72KB
struts-logic.tld 14KB
validator-rules.xml 13KB
lib
jstl.jar 23KB
standard.jar 403KB
classes
com
mxx
dao
BookDao.class 2KB
BaseDao.class 2KB
bookServlet
BookServlet.class 3KB
entity
BookInfo.class 1KB
yourcompany
struts
ApplicationResources.properties 93B
MyPage.jsp 2KB
index.jsp 841B
META-INF
MANIFEST.MF 39B
.myeclipse
src
com
mxx
dao
BaseDao.java 1KB
BookDao.java 1KB
bookServlet
BookServlet.java 4KB
entity
BookInfo.java 631B
yourcompany
struts
ApplicationResources.properties 93B
.mystrutsdata 262B
.classpath 665B
共 28 条
- 1
资源评论
- shenzhenclass2012-09-06虽然看着简单,,,但是不能运行,,,无用处
mxx_0720
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab实现用有限元法计算电磁场的Matlab工具 .rar
- 基于matlab实现有限元算法 计算电磁场问题 边界条件包括第一类边界和第二类边界.rar
- 基于matlab实现用于计算不同车重下的电动汽车动力性和经济性.rar
- 基于matlab实现遗传算法求解多车场车辆路径问题 有多组算例可以用.rar
- 浏览器.apk
- 基于matlab实现是一个matlab中的power system 中搭建的一个模型
- 基于JSP毕业设计-教学管理系统(源代码+论文).zip
- 基于JSP毕业设计-家政管理系统-毕业设计.zip
- 基于Python实现淘宝商品评论采集(含逆向)源代码
- 基于matlab实现多目标进化算法NSGAⅡ&Matlab讲解.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功