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

📄 delserchcard.java

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

import model.*;
import java.util.*;

public class DelSerchCard extends ShowCategory
{
	public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
    {
    	int CardID = Integer.parseInt(req.getParameter("CardID"));
    	String Condition = req.getParameter("Condition");
    	String CPath = req.getParameter("CPath");
    	String Keyword = (String)req.getParameter("Keyword");
    	int pagenum = Integer.parseInt(req.getParameter("pagenum"));
    	String Sort_Condition = (String)req.getParameter("sortcondition");      //2008.11.19修改  取得排序方式
    	System.out.println("DelSerchCard By: " + Sort_Condition);
    	int pagecount = 0;
    	int total = 0;
    	boolean result = false;
    	CardCom com = new CardCom("jdbc:mysql://localhost/mybbs","root", "root123");
        
        Vector vc = new Vector();
        if(((Boolean)req.getSession().getAttribute("AdminOrNot")).booleanValue())//如果是管理员
        {
           result = com.delCard(CardID);
           if(Condition.equals("ByContent"))    //如果按内容或关键字搜索
           {
        	   /*Vector temp = com.getAllSerchCard(Keyword, CPath,Sort_Condition);
        	   total = temp.size();  
        	   for(int i = (pagenum-1)*8;(i < pagenum*8)&&(i < total);++i)
        	   {
        		   vc.add(temp.get(i));
        	   }*/
        	   total = com.getCountSerchCard(CPath, Keyword, Sort_Condition);
        	   vc = com.getAllCardByKeyword(Keyword, CPath, pagenum, Sort_Condition);
        	   
        	  if(total != 0 && vc.size()==0 && pagenum > 1)
        	  {
        		  pagenum = pagenum -1;
        		  /*for(int i = (pagenum-1)*8;(i < pagenum*8)&&(i < total);++i)
           	      {
           		      vc.add(temp.get(i));
           	      }*/
        		  vc = com.getAllCardByKeyword(Keyword, CPath, pagenum, Sort_Condition);
        	  }

        	   if(total % 8==0)
   				   pagecount  = total/8;
   			   else
   				   pagecount = ((int)total/8)+1;
           }
           else
           {
        	   UserCom com2 = new UserCom("jdbc:mysql://localhost/mybbs","root", "root123");
       		   total = com2.getTieziShuliang(Keyword);
       		   if(total!=0)
       		   {
       			   vc = com.getCardByUserName(Keyword, pagenum,Sort_Condition);
       			   if(vc.size()==0&&pagenum>1)
       			   {
       				   pagenum = pagenum -1;
       				   vc = com.getCardByUserName(Keyword, pagenum,Sort_Condition);
       			   }
       			   if(total % 8==0)
       				   pagecount  = total/8;
       			   else
       				   pagecount = ((int)total/8)+1;
       		   }   
           }
           req.setAttribute("NewsCount",new Integer(total) );
           req.setAttribute("allcard", vc);
           req.setAttribute("Condition", Condition);
           req.setAttribute("cname","all");
           req.setAttribute("cpath",CPath);
           req.setAttribute("Keyword",Keyword);
           req.setAttribute("pagenum",String.valueOf(pagenum));  //当前页数
       	   req.setAttribute("pagecount", String.valueOf(pagecount));//总共需要多少页面数
       	   req.setAttribute("command", "guanli");
       	   req.setAttribute("sortcondition", Sort_Condition); //2008.11.19修改  排序
       	   if(result==true)
    		   req.setAttribute("Message","删除文章成功,页面已被刷新");   
    	   else
    		   req.setAttribute("Message","删除文章失败,页面已被刷新");
    	   tiaoZhuan(req,res,"/ShowSerchCard.jsp");
       }
     
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -