📄 listservlet.java
字号:
package mvc;
import java.io.IOException;
import javax.servlet.ServletException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ListServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("GBK");
String condition = request.getParameter("condition");
String page= request.getParameter("jumpPage");
int pageNum = 1;
if(page!=null){
try{
pageNum = Integer.parseInt(page);
}catch(Exception ex){}
}
try{
//调用业务bean
ProductPage pb=new ProductPage();
PageBean pageBean = pb.listData(pageNum,condition);
//把PageBean保存到request对象中。
request.setAttribute("pageBean",pageBean);
}catch(Exception e){}
/**
*把视图派发到viewProduct.jsp
*/
javax.servlet.RequestDispatcher dis=request.getRequestDispatcher("/list.jsp");
dis.forward(request,response);
}
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doGet(req,resp);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -