码迷,mamicode.com
首页 > Web开发 > 详细

JSP---一个Servlet处理多个请求操作

时间:2014-07-18 10:27:34      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:http   os   io   for   cti   re   

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">//更新

JSP---一个Servlet处理多个请求操作,布布扣,bubuko.com

JSP---一个Servlet处理多个请求操作

标签:http   os   io   for   cti   re   

原文地址:http://www.cnblogs.com/beast-king/p/3852691.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!