步骤:
1.编写query.jsp代码
<%@ page import="com.mvcapp.entity.Customer" %><%@ page import="java.util.List" %><%-- Created by IntelliJ IDEA. User: dell Date: 2019/7/4 Time: 19:34 To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %>Title
2.delete.do
private void delete(HttpServletRequest req, HttpServletResponse resp) { String idStr = req.getParameter("id"); int id = 0; //try...catch的作用:防止idStr不能转为int类型 //若不能转则id=0,无法进行任何的删除操作 try { id = Integer.parseInt(idStr); customerDAO.delete(id); }catch (Exception e){ } try { resp.sendRedirect("query.do"); } catch (IOException e) { e.printStackTrace(); } }