今天和团队对第二阶段项目的实现目标做了设计,进行了分工,本人对项目的结构进行了熟悉 (毕竟有一段时间了),写了对文档进行删除的Servlet部分。
package Servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import dao.dao; import entity.Book; import net.sf.json.JSONObject; public class DeleteBookServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html; charset=utf-8"); String bookname =request.getParameter("bookname"); String bookpath =request.getParameter("bookpath"); String createuser=request.getParameter("createuser"); String createdate=request.getParameter("createdate"); Book book =new Book(bookname,bookpath,createuser,createdate); dao dao =new dao(); PrintWriter out = response.getWriter(); JSONObject json=new JSONObject(); if(dao.delete(book)) { json.put("result", 1); out.print(json); }else { json.put("result", 0); out.print(json); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }