showcardlist.java
来自「一个信息发布系统 基于jsp+servlet+tomcat 用户分管理员跟普通用」· Java 代码 · 共 57 行
JAVA
57 行
package control;
import java.io.IOException;
import javax.servlet.http.*;
import javax.servlet.*;
import java.util.*;
public class ShowCardList extends HttpServlet
{
public void init(ServletConfig config)throws ServletException
{
super.init(config);
}
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
doPost(req,res);
}
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
req.setCharacterEncoding("gbk");
CardCom com = new CardCom("jdbc:mysql://localhost/mybbs","root", "root123");
CategoryCom com2 = new CategoryCom("jdbc:mysql://localhost/mybbs","root", "root123");
Vector vc = new Vector();
String Yonghu = req.getParameter("user");
String Command = req.getParameter("command");
String CName = req.getParameter("id"); //从提交页面中获得传递过来的参数CName
int pagenum = Integer.parseInt((String)req.getParameter("pagenum")); //取得要显示的网页页码,第一次进入的时候为1
int pagecount = 0;
int total = com2.getCCount(CName); //取得该板块中所有帖子数
if(total % 2==0)
pagecount = total/2;
else
pagecount = ((int)total/2)+1;
if(pagenum<=pagecount)
{
//vc = com.getAllCardBySize(CName, pagenum);
}
else
vc = null;
req.setAttribute("allcard", vc);
req.setAttribute("name", CName);
req.setAttribute("pagenum",String.valueOf(pagenum)); //当前页数
req.setAttribute("pagecount", String.valueOf(pagecount));//总共需要多少页面数
tiaoZhuan(req,res,"/ShowCardList.jsp");//跳转到该页面 显示所有的帖子Card
}
public void tiaoZhuan(HttpServletRequest req,HttpServletResponse res,String page)throws ServletException,IOException
{
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(page);
dispatcher.forward(req, res);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?