protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int cPage;
try {
cPage=Integer.parseInt(request.getParameter("cPage"));
}catch(NumberFormatException e) {
cPage = 1;
}
int numPerpage;
try {
numPerpage=Integer.parseInt(request.getParameter("numPerPage"));
}catch(NumberFormatException e) {
numPerpage = 10;
}
List<Member> members = new AdminService().selectMemberAll(cPage,numPerpage);
request.setAttribute("members", members);
int totalData = new AdminService().selectMemberCount();
int totalPage = (int)Math.ceil((double)totalData / numPerpage);
int pageBarSize = 5;
int pageNo=((cPage-1)/pageBarSize)*pageBarSize+1;
int pageEnd=pageNo+pageBarSize-1;
String pageBar="";
if(pageNo==1) {
pageBar+="<span>[이전]</span>";
}else {
pageBar+="<a href='"+request.getRequestURI()
+"?cPage="+(pageNo-1)+"'>[이전]</a>";
}
while(!(pageNo>pageEnd||pageNo>totalPage)) {
if(pageNo==cPage) {
pageBar+="<span>"+pageNo+"</span>";
}else {
pageBar+="<a href='"+request.getRequestURI()
+"?cPage="+pageNo+"'>"+pageNo+"</a>";
}
pageNo++;
}
if(pageNo>totalPage) {
pageBar+="<span>[다음]</span>";
}else {
pageBar+="<a href='"+request.getRequestURI()+"?cPage="+pageNo+"'>[다음]</a>";
}
request.setAttribute("pageBar", pageBar);
request.getRequestDispatcher("/views/admin/managemember.jsp").forward(request, response);
}