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

📄 wtservlet.java

📁 一个简单的同学录
💻 JAVA
字号:
package txl.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import txl.tools.*;

import javax.servlet.RequestDispatcher;

public class WtServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public WtServlet() {
		super();
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException {
	String mod = request.getParameter("mod");
	if(mod.equals("add")){
		TxlUserBean txl = new TxlUserBean();
		txl.setName(request.getParameter("name"));
		txl.setDz(request.getParameter("dz"));
		txl.setDh(request.getParameter("dh"));
		txl.setOicq(request.getParameter("oicq"));
		txl.setYb(request.getParameter("yb"));
		DbBean db = new DbBean();
		db.addnew(txl);
		List list = db.ShowInfo();
		db.close();
		request.setAttribute("list1", list);
		//response.sendRedirect("/txl/txllist.jsp");
		System.out.println("111111");
	   RequestDispatcher rd = request.getRequestDispatcher("/txllist.jsp");
	   rd.forward(request, response);
	   System.out.println("222222");
	}
	if(mod.equals("del")){
		String id = request.getParameter("id");
		DbBean db = new DbBean();
		db.delUser(id);
		List list = db.ShowInfo();
		db.close();
	   request.setAttribute("list1", list);
	   RequestDispatcher rd = request.getRequestDispatcher("/txllist.jsp");
	   rd.forward(request, response);
	}
	if(mod.equals("med")){
		String id = request.getParameter("id");
		DbBean db = new DbBean();
		TxlUserBean txl = new TxlUserBean();
		txl = db.listUser(id);
		db.close();
		request.setAttribute("txlmd", txl);
		RequestDispatcher rd = request.getRequestDispatcher("/txlmod.jsp");
	    rd.forward(request, response);			
	}
	if(mod.equals("mmm")){
		TxlUserBean txl = new TxlUserBean();
		txl.setName(request.getParameter("name"));
		txl.setDz(request.getParameter("dz"));
		txl.setDh(request.getParameter("dh"));
		txl.setOicq(request.getParameter("oicq"));
		txl.setYb(request.getParameter("yb"));
		txl.setId(request.getParameter("id"));
		DbBean db = new DbBean();
		db.txlMod(txl);
		List list = db.ShowInfo();
		db.close();
	   request.setAttribute("list1", list);
	   RequestDispatcher rd = request.getRequestDispatcher("/txllist.jsp");
	   rd.forward(request, response);
	}

}


	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

            doGet(request,response);
	}

}

⌨️ 快捷键说明

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