packagecom.frog.vote.servlet.front;importjava.io.IOException;importjava.sql.Timestamp;importjava.util.ArrayList;importjava.util.List;importjavax.servlet.ServletContext;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importcom.frog.vote.bean.UserBean;importcom.frog.vote.cons.Const;importcom.frog.vote.dao.entity.Vote;importcom.frog.vote.factory.ServiceFactory;publicclassVoteServletextendsHttpServlet{ @Override protectedvoiddoGet(HttpServletRequestreq,HttpServletResponseresp) throwsServletException,IOException { doPost(req,resp); } @Override protectedvoiddoPost(HttpServletRequestreq,HttpServletResponseresp) throwsServletException,IOException { req.setCharacterEncoding("gbk"); resp.setContentType("text/html;charset=gbk"); //先取出操作参数 Stringaction=req.getParameter("action"); ServletContextapplication=getServletContext(); //显示的列表 if("show".equals(action)) { //调用service层方法得到所有的 Stringtemp=req.getParameter("page"); intpage=1; if(temp!=null) { try { page=Integer.parseInt(temp); } catch(NumberFormatExceptione) { e.printStackTrace(); } } UserBeanub=(UserBean)req.getSession().getAttribute(Const.USER); intuid=ub.getId(); req.setAttribute("page",ServiceFactory .getVoteService().listUserPage(page,uid)); application.getRequestDispatcher("/WEB-INF/front/list.jsp") .forward(req,resp); return; } elseif("save".equals(action)||"update".equals(action)) { Stringsid=req.getParameter("id"); String[]answers=req.getParameterValues("choice"); Listlist=newArrayList(); inttemp; for(Stringanswer:answers){temp=Integer.parseInt(answer);list.add(temp);} inttid=Integer.parse
1