1、Servlet
public void excute(HttpServletRequest request, HttpServletResponse response)
throws Exception {
request.setCharacterEncoding("utf-8");
String operate = request.getParameter("operate");
if (operate == null || operate.equals("")) {
operate = "list";
}
if (operate.equals("save")) {
save(request, response);
} else if (operate.equals("edit")) {
edit(request, response);
} else if (operate.equals("update")) {
update(request, response);
} else if (operate.equals("delete")) {
delete(request, response);
}
}
public void list(HttpServletRequest request, HttpServletResponse response){//todo}
public void save(HttpServletRequest request, HttpServletResponse response){//todo}
public void edit(HttpServletRequest request, HttpServletResponse response){//todo}
public void update(HttpServletRequest request, HttpServletResponse response){//todo}
public void delete(HttpServletRequest request, HttpServletResponse response){//todo}
2.jsp
<form name="formAdd" action="pet.do?operate=save" method="post">//增
<a href="pet.do?operate=edit&id=${pet.pet_id}">修改</a> //改
<a href="pet.do?operate=delete&id=${pet.pet_id}">删除</a> //删
<form name="formEdit" action="pet.do?operate=update" method="post">//更新