📄 allbespokeservlet.java
字号:
package com.pet.pets.action;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.pet.pets.model.DAO.PetDao;
import com.pet.pets.model.DAO.impl.Petimpl;
import com.pet.bbs.model.DAO.BbsDao;
import com.pet.bbs.model.DAO.impl.Bbsimpl;
public class AllBespokeServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GB2312";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
String svid = request.getParameter("vid");
int vid = Integer.parseInt(svid);
HttpSession session = request.getSession();
//实力化业务逻辑接口实现类
PetDao queryEmployee = new Petimpl();
//得到会话中是否有当前页数的值
String pageIndexSessionName = "";
int num = 0;
//如果没有当前页数的值,则认定为第一次提交页面,为首页
if (request.getParameter("pageIndexSessionName") != null) {
pageIndexSessionName = (String) request.getParameter(
"pageIndexSessionName").trim();
num = 5 * Integer.parseInt(pageIndexSessionName);
}
//按照分页参数到接口实现方法中进行查询
ArrayList employeeList = queryEmployee.allBespoke(vid,num);
request.setAttribute("allb", employeeList);
//查询总记录数
String count = "";
count = queryEmployee.queryEmployeeAll(vid);
//传递分页参数:rowCountSessionName表的总数,pageNumberSessionName每页的显示条数
session.setAttribute("rowCountSessionName", count);
session.setAttribute("pageNumberSessionName", "5");
session.setAttribute("pageIndexSessionName", pageIndexSessionName);
request.getRequestDispatcher("seebespoke.jsp").forward(request,response);
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
doGet(request, response);
}
//Clean up resources
public void destroy() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -