showcategory.java
来自「一个信息发布系统 基于jsp+servlet+tomcat 用户分管理员跟普通用」· Java 代码 · 共 44 行
JAVA
44 行
package control;
import java.io.IOException;
import javax.servlet.http.*;
import javax.servlet.*;
import model.*;
import java.util.*;
public class ShowCategory extends HttpServlet
{
private static Vector vc ;
//public ShowCategory(){} //去掉该注释的时候 ShowChex出错 为什么
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
{
CategoryCom com2 = new CategoryCom("jdbc:mysql://localhost/mybbs?useUnicode=true&characterEncoding=gbk","root", "root123");
vc = com2.getAllCatefory(); //用来存储Category
String command = (String)req.getParameter("command");
req.setAttribute("demo", vc);
req.setAttribute("command", command);
tiaoZhuan(req,res,"/DengLuOK.jsp");
}
public static Vector getCategoryList()
{
return vc;
}
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 + -
显示快捷键?