⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showallcardlist.java

📁 一个信息发布系统 基于jsp+servlet+tomcat 用户分管理员跟普通用户 普通用户有发布信息 查询信息 修改信息 回复信息 管理员拥有普通用户的功能 此外还具有删除信息 管理信息的回复的功能
💻 JAVA
字号:
package control;
import java.io.IOException;
import javax.servlet.http.*;
import javax.servlet.*;

import java.util.*;

public class ShowAllCardList 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 Command = req.getParameter("command");
    	int pagenum = Integer.parseInt((String)req.getParameter("pagenum")); //取得要显示的网页页码,第一次进入的时候为1
    	int pagecount = Integer.parseInt((String)req.getParameter("pagecount"));
    	String CName = (String)req.getParameter("cname");
    	String CPath = req.getParameter("cpath");
    	String Sort_Condition = (String)req.getParameter("sortcondition");      //2008.11.19修改  取得排序方式
    	System.out.println("ShowAllCardList By: " + Sort_Condition);   //2008.11.19修改  取得排序方式
    	int total = com2.getCCount(CName);  

    	if(total % 8==0)
    		pagecount  = total/8;
    	else
    		pagecount = ((int)total/8)+1;
    	System.out.println("共需要"+pagecount+"页");
    	if(pagenum<=pagecount)
    	{
    		if(CPath.equals("all"))
    		   vc = com.getAllCard(pagenum,Sort_Condition);
    		else
    		   vc= com.getAllCardBySize(CPath, pagenum,Sort_Condition);	
    		
    	}
    	else
    		vc = null;   
    	if(Command.equals("guanli"))
    		req.setAttribute("Message","欢迎进入管理文章页面");
    	else
    		req.setAttribute("Message","欢迎进入文章列表页面");
    	req.setAttribute("NewsCount",new Integer(total));
    	req.setAttribute("cname", CName);
    	req.setAttribute("cpath", CPath);
    	req.setAttribute("allcard", vc);
    	req.setAttribute("pagenum",String.valueOf(pagenum));  //当前页数
    	req.setAttribute("pagecount", String.valueOf(pagecount));//总共需要多少页面数
    	req.setAttribute("command", Command);
    	req.setAttribute("sortcondition", Sort_Condition); //2008.11.19修改  排序
    	tiaoZhuan(req,res,"/ShowAllCardList.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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -