管理员在该界面可以增加、删除、修改图书分类信息,操作效果如图。
修改图书分类功能的代码如下: package com.cya.controller; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.cya.dao.BookDao; import com.cya.dao.TypeDao; /** * Servlet implementation class updateBookTypeServlet */ @WebServlet("/updateBookTypeServlet") public class updateBookTypeServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public updateBookTypeServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub // response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub // doGet(request, response); //修改图书类型信息 request.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8"); String name = request.getParameter("name"); int tid = Integer.parseInt(request.getParameter("tid")); TypeDao typedao = new TypeDao(); typedao.updateTypeBook(tid, name); response.sendRedirect("/manage_books/books/admin/admin_booksType.jsp"); } } 06 最后的话(下载源码)
你若需要下载源码,请关注微信公众号:C you again,回复 “基于web的图书管理系统” 获取 。
你也可以扫码关注