Java 前臺加後臺精品圖書管理系統的實現

一、項目簡述

功能包括: 登錄註冊,辦理借閱。借閱記錄,預約借閱,借出未還, 借閱逾期,學生管理,圖書管理,書庫分類查詢搜索。

二、項目運行

環境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

項目技術: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。

修改圖書類型信息代碼:

/**
 * 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("/books/admin_booktype.jsp");
	}
 
}

登錄圖書管理系統主頁面代碼:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import = "com.rain.bean.AdminBean,com.rain.bean.HistoryBean,com.rain.dao.AdminDao" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="zh-CN" class="ax-vertical-centered">
<head>
	<meta charset="UTF-8">
	<title>圖書館管理系統</title>
	    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="static/css/bootstrap.min.css" rel="external nofollow" >
	    <link rel="stylesheet" href="static/css/bootstrap-theme.min.css" rel="external nofollow" >
    <link rel="stylesheet" href="static/css/bootstrap-admin-theme.css" rel="external nofollow"  rel="external nofollow" >
        <link rel="stylesheet" href="static/css/bootstrap-admin-theme.css" rel="external nofollow"  rel="external nofollow" >
        <script src="static/js/bootstrap.min.js"></script>
        <script src="static/jQuery/jquery-3.1.1.min.js"></script>
            <script src="static/js/bootstrap-dropdown.min.js"></script>
                      
              <script src="static/ajax-lib/ajaxutils.js"></script>
            <script src="static/js/adminUpdateInfo.js"></script>
             <script src="static/js/adminUpdatePwd.js"></script>
       
</head>
 
 
 
<script src="static/js/jquery.min.js"></script>
<script src="static/js/bootstrap.min.js"></script>
 
 
<body class="bootstrap-admin-with-small-navbar">
<%
AdminBean admin = new AdminBean();
String aid = (String)session.getAttribute("aid");
AdminDao admindao = new AdminDao();
admin = admindao.get_AidInfo2(aid);
 
%>
    <nav class="navbar navbar-inverse navbar-fixed-top bootstrap-admin-navbar bootstrap-admin-navbar-under-small" role="navigation">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div class="collapse navbar-collapse main-navbar-collapse">
                        <a class="navbar-brand" href="/admin/admin.jsp" rel="external nofollow" ><strong>歡迎使用圖書館管理系統</strong></a>
                        <ul class="nav navbar-nav navbar-right">
                            <li class="dropdown">
                                <a href="#" rel="external nofollow"  role="button" class="dropdown-toggle" data-hover="dropdown"> <i class="glyphicon glyphicon-user"></i> 歡迎您, <s:property value="#session.admin.name"/> <i class="caret"></i></a>
                            
                                 <ul class="dropdown-menu">
                                     <li><a href="#updateinfo" rel="external nofollow"  data-toggle="modal">個人資料</a></li>
                                      <li role="presentation" class="divider"></li>
                                       <li><a href="#updatepwd" rel="external nofollow"  data-toggle="modal">修改密碼</a></li>
                                        <li role="presentation" class="divider"></li>
                                    <li><a href="/books/login.jsp" rel="external nofollow" >退出</a></li>
                                </ul>
                                
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </nav>
 
    <div class="container">
        <!-- left, vertical navbar & content -->
        <div class="row">
            <!-- left, vertical navbar -->
            <div class="col-md-2 bootstrap-admin-col-left">
                <ul class="nav navbar-collapse collapse bootstrap-admin-navbar-side">
                    <li>
                        <a href="/books/admin_book.jsp" rel="external nofollow" ><i class="glyphicon glyphicon-chevron-right"></i> 圖書管理</a>
                    </li>
                    <li>
                        <a href="/books/admin_user.jsp" rel="external nofollow" ><i class="glyphicon glyphicon-chevron-right"></i> 讀者管理</a>
                    </li>
                    <li>
                        <a href="/books/admin_booktype.jsp" rel="external nofollow" ><i class="glyphicon glyphicon-chevron-right"></i> 圖書分類管理</a>
                    </li>
                    <li>
                        <a href="/books/admin_borrow.jsp" rel="external nofollow" ><i class="glyphicon glyphicon-chevron-right"></i> 圖書借閱信息</a>
                    </li>
                    <li>
                        <a href="/books/admin_history.jsp" rel="external nofollow" ><i class="glyphicon glyphicon-chevron-right"></i> 圖書歸還信息</a>
                    </li>
                  
                </ul>
                
            </div>
 
            <!-- content -->
            <div class="col-md-10">
                
                  
                <div class="row">
                    <div class="col-md-6">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <div class="text-muted bootstrap-admin-box-title">圖書管理</div>
                            </div>
                            <div class="bootstrap-admin-panel-content">
                                <ul>
                                    <li>根據圖書編號、圖書名稱查詢圖書基本信息</li>
                                    <li>添加、修改、刪除圖書</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <div class="text-muted bootstrap-admin-box-title">圖書分類管理</div>
                            </div>
                            <div class="bootstrap-admin-panel-content">
                                <ul>
                                    <li>根據分類名稱查詢圖書分類信息</li>
                                    <li>添加、修改、刪除圖書分類</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <div class="text-muted bootstrap-admin-box-title">圖書借閱</div>
                            </div>
                            <div class="bootstrap-admin-panel-content">
                                <ul>
                                    <li>展示所有正在借閱圖書的信息</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <div class="text-muted bootstrap-admin-box-title">圖書歸還</div>
                            </div>
                            <div class="bootstrap-admin-panel-content">
                                <ul>
                                    <li>展示所有已歸還圖書的信息</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                  
                   <div class="col-md-6">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <div class="text-muted bootstrap-admin-box-title">讀者管理</div>
                            </div>
                            <div class="bootstrap-admin-panel-content">
                                <ul>
                                    <li>根據賬號、姓名查詢讀者基本信息</li>
                                    <li>添加、修改、刪除讀者信息</li>
                                </ul>
                            </div>
                        </div>
                </div>
           
            </div>
            
           
            
        </div>
    </div>
    
    
    
    
    
    
    
    
    
<!-------------------------------------------------------------->  
                 
                   <form class="form-horizontal" method="post" action="/books/AdminServlet">   <!--保證樣式水平不混亂-->                  
                                     <!-- 模態框(Modal) -->
				<div class="modal fade" id="updatepwd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
									&times;
								</button>
								<h4 class="modal-title" id="myModalLabel">
									修改密碼
								</h4>
							</div>
							<div class="modal-body">
							 
								<!--正文-->
								<input type="hidden" name="tip" value="1">
								<input type="hidden" name="url" value="admin">
							<div class="form-group">
								<label for="firstname" class="col-sm-3 control-label">原密碼</label>
								<div class="col-sm-7">
									<input type="password" class="form-control" name="password" id="oldPwd"  placeholder="請輸入原密碼">
										<label class="control-label" for="oldPwd" style="display: none"></label>				
								</div>
							</div>	
							
							<div class="form-group">
								<label for="firstname" class="col-sm-3 control-label">新密碼</label>
								<div class="col-sm-7">
									<input type="password" class="form-control" name="password2" id="newPwd"  placeholder="請輸入新密碼">
										<label class="control-label" for="newPwd" style="display: none"></label>			
								</div>
							</div>	
							
								<!--正文-->
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal">關閉
								</button>
								<button type="submit" class="btn btn-primary" >
									修改
								</button>
							</div>
						</div><!-- /.modal-content -->
					</div><!-- /.modal -->
				</div>
 
				</form>	
                                   <!-------------------------------------------------------------->
                                   
                                   <!-------------------------個人資料模糊框------------------------------------->  
                 
                   <form class="form-horizontal" method="post" action="/books/AdminServlet">   <!--保證樣式水平不混亂-->                  
                                     <!-- 模態框(Modal) -->
				<div class="modal fade" id="updateinfo" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
									&times;
								</button>
								<h4 class="modal-title" id="ModalLabel">
									個人資料
								</h4>
							</div>
							
							<div class="modal-body">
							 
								<!--正文-->
								<input type="hidden" name="tip" value="2">
								<input type="hidden" name="url" value="admin">
							<div class="form-group">
								<label for="firstname" class="col-sm-3 control-label">真實姓名</label>
								<div class="col-sm-7">
			<input type="text" class="form-control" id="name" name="name" placeholder="請輸入您的真實姓名" value='<% out.write(admin.getName());%>'>
										<label class="control-label" for="name" style="display: none"></label>			
								</div>
							</div>	
							
							<div class="form-group">
								<label for="firstname" class="col-sm-3 control-label">手機號</label>
								<div class="col-sm-7">
			<input type="text" class="form-control" id="phone" name="phone" placeholder="請輸入您的手機號" value='<% out.write(admin.getPhone());%>'>
											<label class="control-label" for="phone" style="display: none"></label>				
								</div>
							</div>	
							
							
							<div class="form-group">
								<label for="firstname" class="col-sm-3 control-label">郵箱</label>
								<div class="col-sm-7">
			<input type="text" class="form-control" id="email" name="email"  placeholder="請輸入您的郵箱" value='<% out.write(admin.getEmail());%>'>
											<label class="control-label" for="email" style="display: none"></label>				
								</div>
							</div>	
							
								<!--正文-->
								
								
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal">關閉
								</button>
								<button type="submit" class="btn btn-primary" >
									修改
								</button>
							</div>
						</div><!-- /.modal-content -->
					</div><!-- /.modal -->
				</div>
 
				</form>	
                                   <!-------------------------------------------------------------->
    
    
    
    
    
    <div class="modal fade" id="modal_info" tabindex="-1" role="dialog" aria-labelledby="addModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="infoModalLabel">提示</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-lg-12" id="div_info"></div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" id="btn_info_close" data-dismiss="modal">關閉</button>
            </div>
        </div>
    </div>
</div>
    
    
    
    
    
</body>
</html>

圖書操作代碼:

/**
 * @description: 圖書操作
 */
@Controller
@RequestMapping("/admin/ch")
public class LibraryController {
    //註入
    @Autowired
    private LibraryService libraryService;
 
 
 
    /**
     * 修改圖書信息
     *
     * @param uploadFile 上傳圖片
     * @param library    圖書信息
     * @return
     */
    @RequestMapping(value = "/updateBook", method = RequestMethod.POST)
    public String updateBook(MultipartFile uploadFile, TbLibrary library, HttpServletRequest request) {
        try {
            libraryService.updateOrSaveLibrary(uploadFile, library,request);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "redirect:/admin/ch/loan_bookList.action";
    }
 
    /**
     * 添加圖書
     *
     * @param uploadFile 上傳圖片
     * @param library    圖書信息
     * @return
     */
    @RequestMapping(value = "/addBook", method = RequestMethod.POST)
    public String addBook(MultipartFile uploadFile, TbLibrary library, HttpSession session,HttpServletRequest request) {
        ActiveAdmin activeAdmin = (ActiveAdmin) session.getAttribute("activeAdmin");
        library.setManagerId(activeAdmin.getUserid());
        try {
            libraryService.updateOrSaveLibrary(uploadFile, library,request);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "redirect:/admin/ch/loan_bookList.action";
    }
 
    /**
     * 根據 圖書id  刪除 圖書
     *
     * @param id 圖書id
     * @return
     */
    @RequestMapping("/delBookById")
    public String delBook(int id) {
        libraryService.delBookById(id);
        return "redirect:/admin/ch/loan_bookList.action";
    }
 
}

以上就是Java 前臺加後臺精品圖書管理系統實現的詳細內容,更多關於Java 圖書管理系統的資料請關註WalkonNet其它相關文章!

推薦閱讀: