利用Servlet和JSP设计并实现简单的图书管理系统

2026/1/21 11:36:25

request.setAttribute(\

BookDBAccess dbAccess=new BookDBAccess();

List list=dbAccess.findAllBookByMostCon(bookName, ISBN, author, publishCom);

request.setAttribute(\

request.getRequestDispatcher(\response); } }

<7>显示图书清单

package com.imut.servlet; import java.io.IOException; import java.util.List;

import javax.servlet.ServletException; import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.imut.javabean.BookDBAccess; import com.imut.javabean.User;

import com.imut.javabean.UserDBAccess;

public class ListAllBookServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); }

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding(\ response.setCharacterEncoding(\ BookDBAccess dbAccess=new BookDBAccess(); List list=dbAccess.findAllBook(); request.setAttribute(\

request.getRequestDispatcher(\response); } }

<8>用户定义

package com.imut.javabean; public class User {

private int userId; private String name; private String password; private String sex; private String feature; private String privence; private String author; private int userType; public User() { }

public User(int userId,String name, String password, String sex, }

public int getUserId() { }

public void setUserId(int userId) { }

public String getName() { }

public void setName(String name) { }

public String getPassword() { }

public void setPassword(String password) { }

public String getSex() {

this.password = password; return password; this.name = name; return name;

this.userId = userId; return userId;

String privence, String author,int userType) {

String feature,

this.userId = userId; this.name = name;

this.password = password; this.sex = sex;

this.feature = feature; this.privence = privence; this.author = author; this.userType = userType;

return sex;

}

public void setSex(String sex) { this.sex = sex;

}

public String getFeature() { return feature; }

public void setFeature(String feature) { this.feature = feature; }

public String getPrivence() { return privence;

}

public void setPrivence(String privence) { this.privence = privence; }

public String getAuthor() { return author;

}

public void setAuthor(String author) { this.author = author; }

public int getUserType() { return userType; }

public void setUserType(int userType) { this.userType = userType; }

}

<9>用户数据库

package com.imut.javabean; import java.sql.Connection;

import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException;

import com.imut.commmon.ConnectionFactory; import com.imut.commmon.ResourceClose; public class UserDBAccess { public User login(String name,String password) { User user=null; Connection conn=null;

PreparedStatement pstmt=null;

ResultSet rs=null;

}

}

try{ }

return user;

conn=ConnectionFactory.getConnection();

String sql=\pstmt=conn.prepareStatement(sql); pstmt.setString(1, name); pstmt.setString(2, password); rs=pstmt.executeQuery(); if(rs.next()){ }

e.printStackTrace();

ResourceClose.close(rs, pstmt, conn);

user=new User();

user.setUserId(rs.getInt(1)); user.setName(rs.getString(2)); user.setPassword(rs.getString(3)); user.setSex(rs.getString(4)); user.setFeature(rs.getString(5)); user.setPrivence(rs.getString(6)); user.setAuthor(rs.getString(7)); user.setUserType(rs.getInt(8));

password=?\

}catch (SQLException e) { }finally{

<10>图书定义

package com.imut.javabean; public class Book {

private int bookId; private String bookName; private String author; private String ISBN; private String publishCom; private float price;

private String publishDate; private String remark; public Book() { }

public Book(int bookId, String bookName, String isbn, String author,

String publishCom, float price, String publishDate, String

remark) {

this.bookId = bookId;


利用Servlet和JSP设计并实现简单的图书管理系统.doc 将本文的Word文档下载到电脑
搜索更多关于: 利用Servlet和JSP设计并实现简单的图书管理系统 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219