-
大小: 577KB文件类型: .rar金币: 1下载: 0 次发布日期: 2021-06-04
- 语言: Java
- 标签: jsp+servlet+
资源简介
package com.frog.vote.servlet.front;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.frog.vote.bean.UserBean;
import com.frog.vote.cons.Const;
import com.frog.vote.dao.entity.Vote;
import com.frog.vote.factory.ServiceFactory;
public class VoteServlet extends HttpServlet
{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
req.setCharacterEncoding("gbk");
resp.setContentType("text/html;charset=gbk");
// 先取出操作参数
String action = req.getParameter("action");
ServletContext application = getServletContext();
// 显示的列表
if ("show".equals(action))
{
// 调用service层方法得到所有的
String temp = req.getParameter("page");
int page = 1;
if (temp != null)
{
try
{
page = Integer.parseInt(temp);
}
catch (NumberFormatException e)
{
e.printStackTrace();
}
}
UserBean ub = (UserBean)req.getSession().getAttribute(Const.USER);
int uid = ub.getId();
req.setAttribute("page", ServiceFactory
.getVoteService().listUserPage(page,uid));
application.getRequestDispatcher("/WEB-INF/front/list.jsp")
.forward(req, resp);
return;
}
else if ("save".equals(action) || "update".equals(action))
{
String sid = req.getParameter("id");
String[] answers = req.getParameterValues("choice");
List list = new ArrayList();
int temp;
for (String answer : answers)
{
temp = Integer.parseInt(answer);
list.add(temp);
}
int tid = Integer.parse
代码片段和文件信息
package com.frog.vote.bean;
import java.util.ArrayList;
import java.util.List;
/**
* 用来封装所有分要要用到的数据
*
* @author Administrator
*
*/
public abstract class AbstractPageBean
{
/**
* 默认每页显示个数
*/
public static final int DEFAULT_PAGE_NUM = 4;
/**
* 每页最大显示个数
*/
public static final int MAX_PAGE_NUM = 20;
/**
* 显示最多页面数目
*/
public static final int MAX_PAGES = 6;
// 总记录数
private int totalNum;
// 每页显示个数
private int pageNum;
// 总页数
private int totalPage;
// 当前页数
private int currentPage;
private List pages;
/**
* @param totalNum
* @param currentPage
* @param pageNum
*/
public AbstractPageBean(int totalNum int currentPage int pageNum)
{
this.totalNum = totalNum;
pageNum = pageNum > 0 ? pageNum : DEFAULT_PAGE_NUM;
pageNum = pageNum < MAX_PAGE_NUM ? pageNum : MAX_PAGE_NUM;
this.pageNum = pageNum;
totalPage = totalNum % pageNum == 0 ? totalNum / pageNum : totalNum
/ pageNum + 1;
currentPage = currentPage > 0 ? currentPage : 1;
currentPage = currentPage < totalPage ? currentPage : totalPage;
this.currentPage = currentPage;
pages = new ArrayList();
initPages();
}
private void initPages()
{
if (totalPage <= MAX_PAGES)
{
for (int i = 1; i <= totalPage; i++)
{
pages.add(i);
}
}
else if (currentPage <= totalPage / 2 && currentPage <= MAX_PAGES / 2)
{
for (int i = 1; i <= MAX_PAGES; i++)
{
pages.add(i);
}
}
else if (currentPage >= totalPage / 2 && (totalPage-currentPage) <= MAX_PAGES / 2)
{
for (int i = 0j=totalPage-MAX_PAGES+1; i < MAX_PAGES; i++j++)
{
pages.add(j);
}
}
else
{
for (int i = 0 j=currentPage-MAX_PAGES/2; i < MAX_PAGES; i++j++)
{
pages.add(j);
}
}
}
public int getTotalNum()
{
return totalNum;
}
public int getPageNum()
{
return pageNum;
}
public int getTotalPage()
{
return totalPage;
}
public int getCurrentPage()
{
return currentPage;
}
/**
* 是否是第一页
*
* @return
*/
public boolean isFirstPage()
{
return currentPage == 1;
}
/**
* 是否是尾页
*
* @return
*/
public boolean isLastPage()
{
return currentPage == totalPage;
}
public int getPrePage()
{
return currentPage - 1;
}
public int getNextPage()
{
return currentPage + 1;
}
public List getPages()
{
return pages;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 456 2009-11-26 14:49 work_vote\.classpath
文件 295 2009-12-01 21:25 work_vote\.myme
文件 1227 2009-11-24 21:13 work_vote\.project
文件 2571 2009-11-26 14:30 work_vote\src\com\frog\vote\bean\AbstractPageBean.java
文件 598 2009-11-28 15:27 work_vote\src\com\frog\vote\bean\AnswerBean.java
文件 775 2009-11-27 09:48 work_vote\src\com\frog\vote\bean\CurrentThemeBean.java
文件 522 2009-11-26 16:45 work_vote\src\com\frog\vote\bean\PageBean.java
文件 860 2009-11-26 23:46 work_vote\src\com\frog\vote\bean\ThemeBean.java
文件 671 2009-11-26 14:33 work_vote\src\com\frog\vote\bean\UserBean.java
文件 746 2009-11-27 09:46 work_vote\src\com\frog\vote\bean\UserList.java
文件 759 2009-11-29 21:13 work_vote\src\com\frog\vote\bean\UserNamesBean.java
文件 948 2009-11-29 22:16 work_vote\src\com\frog\vote\bean\UserVoteBean.java
文件 714 2009-11-29 21:15 work_vote\src\com\frog\vote\bean\VoteBean.java
文件 490 2009-11-27 09:51 work_vote\src\com\frog\vote\cons\Const.java
文件 309 2009-11-29 10:15 work_vote\src\com\frog\vote\cons\InitConst.java
文件 3871 2009-11-26 14:32 work_vote\src\com\frog\vote\dao\DB.java
文件 2751 2009-11-28 18:35 work_vote\src\com\frog\vote\dao\entity\Theme.java
文件 1445 2009-11-26 14:31 work_vote\src\com\frog\vote\dao\entity\User.java
文件 1802 2009-11-28 11:12 work_vote\src\com\frog\vote\dao\entity\Vote.java
文件 7699 2009-11-29 08:44 work_vote\src\com\frog\vote\dao\ThemeDao.java
文件 8390 2009-11-29 17:28 work_vote\src\com\frog\vote\dao\UserDao.java
文件 16758 2009-11-29 22:01 work_vote\src\com\frog\vote\dao\VoteDao.java
文件 841 2009-11-26 14:34 work_vote\src\com\frog\vote\factory\DaoFactory.java
文件 1019 2009-11-26 14:34 work_vote\src\com\frog\vote\factory\ServiceFactory.java
文件 1624 2009-11-26 14:34 work_vote\src\com\frog\vote\filter\AdminLoginFilter.java
文件 1281 2009-11-26 14:34 work_vote\src\com\frog\vote\filter\EncodingFilter.java
文件 1457 2009-11-26 14:34 work_vote\src\com\frog\vote\filter\LoginFilter.java
文件 1117 2009-11-26 14:35 work_vote\src\com\frog\vote\filter\PicFiter.java
文件 1670 2009-11-29 10:13 work_vote\src\com\frog\vote\listener\ContextInitialize.java
文件 991 2009-11-29 23:47 work_vote\src\com\frog\vote\listener\SessionAttribute.java
............此处省略130个文件信息
- 上一篇:Android 轮子时间选择器
- 下一篇:一个简单的java计算器实验报告
相关资源
- JSP+servlet+mysql网络订单系统包含数据库
- JSP+Servlet+Mysql的MVC员工管理系统
- java+jsp+servlet+mysql员工和vip客户管理系
- 学生选课信息管理系统jsp+servlet+mysq
- JSP+SERVLET+MYSQL实现的增删改查javaweb小
- jsp+servlet+mysql开发的仓储管理系统
- 网上商城系统jsp+servlet+mysql130909
- JSP+Servlet+mysql写的注册登录模块
- 学生管理系统(JSP+Servlet+MySQL)
- jsp+servlet+MySQL实现的微博项目源码
- jsp+servlet+mysql+学生选课系统(源码+数
评论
共有 条评论