updatecategory.java

来自「一个信息发布系统 基于jsp+servlet+tomcat 用户分管理员跟普通用」· Java 代码 · 共 43 行

JAVA
43
字号
package control;
import java.io.IOException;
import javax.servlet.http.*;
import javax.servlet.*;
import model.*;
import java.util.*;

public class UpdateCategory 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
    {
    	if(((Boolean)req.getSession().getAttribute("AdminOrNot")).booleanValue())//如果是管理员
    	{
    		String CName = req.getParameter("cname");
    		String Detail = req.getParameter("detail");
    		System.out.println(CName+" "+Detail);
    		CategoryCom com = new CategoryCom("jdbc:mysql://localhost/mybbs","root", "root123");
    		com.updateCategory(CName, Detail);
    		Vector vc = com.getAllCatefory();   
    		req.setAttribute("demo", vc);
    		req.setAttribute("command", "guanli");    	
    		tiaoZhuan(req,res,"/DengLuOK.jsp");
    	}
    }
    
    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 + -
显示快捷键?