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

📄 supplyservlet.java

📁 JSP移动商品管理平台源代码.........
💻 JAVA
字号:
package imis_mate.servlet;

import imis_mate.DAO.DAOFactory;
import imis_mate.DAO.SupplyDAO;
import imis_mate.bean.SupplyBean;

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

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SupplyServlet extends HttpServlet {

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

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * 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 {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String pattern = request.getParameter("pattern");
		
		if(pattern.equals("insert")) {
			//添加供应商
			this.insert(request,response);
		} else if(pattern.equals("update")) {
			//更新供应商
			this.update(request,response);
		} else if(pattern.equals("select")) {
			//查询供应商
			this.select(request,response);
		} else if(pattern.equals("delete")) {
			//删除供应商
			this.delete(request,response);
		} else if(pattern.equals("search")) {
			//多条件查询供应商信息
			this.search(request,response);
		}
	}



	private void insert(HttpServletRequest request, HttpServletResponse response) {
		//添加供应商
		
	}

	private void update(HttpServletRequest request, HttpServletResponse response) {
		//更新供应商
		
	}

	private void select(HttpServletRequest request, HttpServletResponse response) {
		//查询供应商
		
	}

	private void delete(HttpServletRequest request, HttpServletResponse response) {
		//删除供应商
		
	}

	private void search(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//多条件查询供应商信息
		SupplyBean supply = new SupplyBean();
		ArrayList<SupplyBean> list = null;
		
		supply.setSupplyName(request.getParameter("supplyName")); //供应商名称
		supply.setAttPerson(request.getParameter("attPerson")); //联系人
		supply.setTele(request.getParameter("tele")); //电话
		supply.setAddr(request.getParameter("addr")); //地址
		
		SupplyDAO supplyDAO = DAOFactory.getInstance().getSupplyDAO();
		try {
			list = supplyDAO.searchSupply(supply);
		} catch (Exception e) {
			// TODO: handle exception
		}
		request.getSession().setAttribute("supplyList", list);
		request.getRequestDispatcher(SEARCH_URL).forward(request, response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}
	private static final String SEARCH_URL = "../imis_mate/Supply_bysearch.jsp"; //搜索数据页面
}

⌨️ 快捷键说明

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