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

📄 zhuce.java

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

import java.io.IOException;
import javax.servlet.http.*;
import javax.servlet.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ZhuCe extends HttpServlet
{
	private String  page1 = "/zhuceOK.jsp";
    private String  page2 = "/zhuceFail.jsp";
    
    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
    {
   	    String name = req.getParameter("username");
   	    String pasw = req.getParameter("password");
   	    int  age  = Integer.parseInt(req.getParameter("age"));
   		UserCom com = new UserCom("jdbc:mysql://localhost/mybbs","root", "root123");
   		boolean result = com.AddUser(name, pasw, age);  //是否添加成功
   		if(result==true)
   			tiaoZhuan(req,res,page1);
   		else
   			tiaoZhuan(req,res,page2);
   	 }
   	    
    public void  tiaoZhuan(HttpServletRequest req,HttpServletResponse res,String page)throws ServletException,IOException
    {
   	 RequestDispatcher tiaozhuan = getServletContext().getRequestDispatcher(page);
   	 tiaozhuan.forward(req, res);
    }
}

⌨️ 快捷键说明

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