一、系统简介
本项目采用eclipse工具开发,bootstrap+jsp+servlet+jquery技术编写,数据库采用的是mysql,navicat开发工具。
系统一共分为2个角色分别是:管理员,用户
二、模块简介
管理员
1、管理员管理
2、用户管理
3、图书管理
4、图书分类管理
5、订单管理
6、登录
用户
1、登录注册
2、浏览网站,图书
3、购物车管理
4、下单,订单管理
项目简介:
难度等级:✩✩✩
用户类型:2角色(管理员,用户)
设计模式:MVC
项目架构:B/S架构
开发语言:Java语言
前端技术:bootstrap+HTML、CSS、JS、JQuery等
后端技术:JSP、servlet框架
运行环境:Windows7或10、JDK1.8
运行工具:本系统采用Eclipse开发,仅支持Eclipse运行,不支持MyEclipse和IDEA运行,因为三者的骨架不一样,强行导入打开运行可能会导致出现未知的错误。(如若想用idea运行,需要转换!!!!)
数 据 库:MySQL5.5/5.7/8.0版本
运行服务器:Tomcat7.0/8.0/8.5/9.0等版本
是否基于Maven环境:否
是否采用框架:是
数据库表数量:7张表
JSP页面数量:20多张
是否有分页:有分页
相关截图
相关代码
登录
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>网上书店登录</title>
<link rel="stylesheet" type="text/css" href="css/login/login.css" />
<script type="text/javascript">
function checkForm(){
var userName=document.getElementById("userName");
var passWord=document.getElementById("passWord");
if(userName.value.length<=0){
alert("请输入用户名!");
userName.focus();
return false;
}
if(passWord.value.length<=0){
alert("请输入密码!");
passWord.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<c:if test="${!empty infoList}">
<c:forEach items="${infoList}" var="i">
<script type="text/javascript">
alert("${i}")
</script>
</c:forEach>
</c:if>
<div>
<h1 id="title">
书城后台管理系统 <sup style="color: red;font-size:14px;"><%=application.getInitParameter("version")%></sup>
</h1>
<div id="login">
<form action="jsp/admin/LoginServlet" method="post"
onsubmit="javascript:return checkForm()">
<p>
<input type="text" name="userName" id="userName" placeholder="用户名">
</p>
<p>
<input type="password" name="passWord" id="passWord"
placeholder="密码">
</p>
<p>
<input type="submit" id="submit" value="登 录">
</p>
<p>
<a style="color:#FFFF;" href="jsp/book/index.jsp">返回网站</a>
</p>
</form>
</div>
</div>
</body>
</html>
package com.shine.bookshop.servlet.admin;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
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.shine.bookshop.bean.Admin;
import com.shine.bookshop.dao.AdminDao;
import com.shine.bookshop.dao.impl.AdminDaoImpl;
/**
* Servlet implementation class LoginServlet
*/
@WebServlet("/jsp/admin/LoginServlet")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String mainPath="index.jsp";
String loginPath="login.jsp";
String userName=request.getParameter("userName");
String passWord=request.getParameter("passWord");
Admin admin=new Admin(userName, passWord);
AdminDao ud=new AdminDaoImpl();
List<String> list=new ArrayList<String>();
if(userName==null) {
list.add("用户名不能为空");
}
if(passWord==null) {
list.add("密码不能为空");
}
if(list.size()==0) {
if(ud.userLogin(admin)) {
request.getSession().setAttribute("adminUser",admin );
response.sendRedirect(mainPath);
return;
}else {
list.add("用户名或密码错误!请重新输入");
}
}
request.setAttribute("infoList", list);
request.getRequestDispatcher(loginPath).forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}