• 大小: 11.44MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-18
  • 语言: Java
  • 标签:

资源简介

基于mysql数据库,实现图书的增删改查

资源截图

代码片段和文件信息

package com.shxt.servlet;

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.shxt.util.FileUploadTool;
import com.shxt.util.JDBCTools;

@WebServlet(“/bookAdd.do“)
public class BookAddServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
}

protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
//处理乱码
request.setCharacterEncoding(“UTF-8“);
FileUploadTool fut = new FileUploadTool(request);
fut.upload();
String name = fut.getParameter(“name“);
String author = fut.getParameter(“author“);
String press = fut.getParameter(“press“);
String date = fut.getParameter(“date“);
String price = fut.getParameter(“price“);
String num = fut.getParameter(“num“);
String fengmian = fut.getParameter(“fengmian“);
if (name==null||““.equals(name)) {
request.setAttribute(“message“ “请输入书名“);
request.setAttribute(“author“ author);
request.setAttribute(“press“ press);
request.setAttribute(“date“ date);
request.setAttribute(“price“ price);
request.setAttribute(“num“ num);

request.getRequestDispatcher(“/book/addbook.jsp“).forward(request response);
return;
}
if (author==null||““.equals(author)) {
request.setAttribute(“message1“ “请输入作者“);
request.setAttribute(“name“ name);
request.setAttribute(“press“ press);
request.setAttribute(“date“ date);
request.setAttribute(“price“ price);
request.setAttribute(“num“ num);

request.getRequestDispatcher(“/book/addbook.jsp“).forward(request response);
return;
}
if (press==null||““.equals(press)) {
request.setAttribute(“message2“ “请输入出版社“);
request.setAttribute(“name“ name);
request.setAttribute(“author“ author);
request.setAttribute(“date“ date);
request.setAttribute(“price“ price);
request.setAttribute(“num“ num);

request.getRequestDispatcher(“/book/addbook.jsp“).forward(request response);
return;
}
if (date==null||““.equals(date)) {
request.setAttribute(“message3“ “请输入出版日期“);
request.setAttribute(“name“ name);
request.setAttribute(“press“ press);
request.setAttribute(“author“ author);
request.setAttribute(“price“ price);
request.setAttribute(“num“ num);

request.getRequestDispatcher(“/book/addbook.jsp“).forward(request response);
return;
}
if (price==null||““.equals(price)) {
request.setAttribute(“message4“ “请输入价格“);
request.setAttribute(“name“ name);
request.setAttribute(“press“ press);
request.setAttribute(“date“ date);
request.setAttribute(“author“ author);
reque

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-07-13 16:29  bookmanager\
     文件         841  2016-07-13 16:29  bookmanager\.classpath
     文件        1044  2016-07-13 16:29  bookmanager\.project
     目录           0  2016-07-13 16:29  bookmanager\.settings\
     文件         567  2016-07-13 16:29  bookmanager\.settings\.jsdtscope
     文件         364  2016-07-13 16:29  bookmanager\.settings\org.eclipse.jdt.core.prefs
     文件         485  2016-07-13 16:29  bookmanager\.settings\org.eclipse.wst.common.component
     文件         345  2016-07-13 16:29  bookmanager\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2016-07-13 16:29  bookmanager\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2016-07-13 16:29  bookmanager\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2016-07-13 16:29  bookmanager\build\
     目录           0  2016-07-14 10:05  bookmanager\build\classes\
     目录           0  2016-07-14 10:05  bookmanager\build\classes\com\
     目录           0  2016-07-14 10:05  bookmanager\build\classes\com\shxt\
     目录           0  2016-07-19 09:33  bookmanager\build\classes\com\shxt\servlet\
     文件        3343  2016-07-18 21:39  bookmanager\build\classes\com\shxt\servlet\BookAddServlet.class
     文件        1605  2016-07-18 22:17  bookmanager\build\classes\com\shxt\servlet\BookDelServlet.class
     文件        1755  2016-07-14 15:29  bookmanager\build\classes\com\shxt\servlet\BookSelServlet.class
     文件        1955  2016-07-18 22:18  bookmanager\build\classes\com\shxt\servlet\BookUpdateServlet.class
     文件        2214  2016-07-18 22:18  bookmanager\build\classes\com\shxt\servlet\BookUpdateShowServlet.class
     文件        3003  2016-07-18 22:18  bookmanager\build\classes\com\shxt\servlet\LoginServlet.class
     文件        3683  2016-07-19 17:34  bookmanager\build\classes\com\shxt\servlet\ReaderAddServlet.class
     文件        1824  2016-07-19 10:41  bookmanager\build\classes\com\shxt\servlet\ReaderAddShowServlet.class
     文件        1617  2016-07-18 22:19  bookmanager\build\classes\com\shxt\servlet\ReaderDelServlet.class
     文件        1869  2016-07-19 09:55  bookmanager\build\classes\com\shxt\servlet\ReaderSelServlet.class
     文件        1969  2016-07-18 22:19  bookmanager\build\classes\com\shxt\servlet\ReaderUpdateServlet.class
     文件        2407  2016-07-19 10:40  bookmanager\build\classes\com\shxt\servlet\ReaderUpdateShowServlet.class
     目录           0  2016-07-14 10:05  bookmanager\build\classes\com\shxt\util\
     文件        4592  2016-07-14 10:06  bookmanager\build\classes\com\shxt\util\FileUploadTool.class
     文件        4760  2016-07-18 19:28  bookmanager\build\classes\com\shxt\util\JDBCTools.class
     目录           0  2016-07-13 16:46  bookmanager\src\
............此处省略68个文件信息

评论

共有 条评论