基于javaweb的校园自行车租赁管理系统(java+jsp+javascript+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

java自行车尺码在哪里 java自行车官网报价_mysql

java自行车尺码在哪里 java自行车官网报价_java_02

java自行车尺码在哪里 java自行车官网报价_sql_03

java自行车尺码在哪里 java自行车官网报价_sql_04

java自行车尺码在哪里 java自行车官网报价_java_05

java自行车尺码在哪里 java自行车官网报价_sql_06

java自行车尺码在哪里 java自行车官网报价_mysql_07

基于javaweb+mysql的校园自行车租赁管理系统(java+JSP+JavaScript+Servlet+Mysql)

项目介绍

本项目分为前后台,包含管理员、站点管理员、用户三种角色;

管理员角色包含以下功能: 管理员登录,管理员管理,车辆类型管理,租赁站点管理,站点管理员管理,自行车信息管理,校园新闻管理,自行车租用统计,友情链接留言系统公告管理等功能。

站点管理员角色包含以下功能: 站点管理员登录,个人资料密码管理,充值管理,租赁归还记录管理,自行车管理,充值记录查询等功能。 用户角色包含以下功能:用户首页,在线留言,用户注册登录,自行车展示,租用自行车,校园新闻查看,租赁记录管理,归还记录管理等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;  5.数据库:MySql 5.7版本; 6.是否Maven项目:否;

技术栈

JSP+CSS+JavaScript+Servlet+mysql

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中CommDAO.java配置文件中的第472行数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入localhost:8080/xxx 登录

登录管理控制层:

public class MainCtrl extends HttpServlet {
public MainCtrl() {
super();
public void destroy() {
super.destroy(); // Just puts “destroy” string in log
// Put your code here
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
public void go(String url,HttpServletRequest request, HttpServletResponse response)
try {
request.getRequestDispatcher(url).forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
public void gor(String url,HttpServletRequest request, HttpServletResponse response)
try {
response.sendRedirect(url);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(“text/html”);
PrintWriter out = response.getWriter();
String ac = request.getParameter(“ac”);
if(ac==null)ac=“”;
CommDAO dao = new CommDAO();
String date = Info.getDateStr();
String today = date.substring(0,10);
String tomonth = date.substring(0,7);
if(ac.equals(“login”))
String username = request.getParameter(“username”);
String password = request.getParameter(“pwd1”);
String utype = request.getParameter(“cx”);
String pagerandom = request.getParameter(“pagerandom”)==null?“”:request.getParameter(“pagerandom”);
String random = (String)request.getSession().getAttribute(“random”);
if(!pagerandom.equals(random)&&request.getParameter(“a”)!=null)
request.setAttribute(“random”, “”);
go(“/index.jsp”, request, response);
else{
String sql1=“”;
if (utype.equals(“注册用户”))
sql1 = “select * from yonghuzhuce where yonghuming='”+username+“’ and mima='”+password+“’ and issh=‘是’”;
else
sql1 = “select * from yuangongxinxi where gonghao='”+username+“’ and mima='”+password+“'”;
List userlist1 = dao.select(sql1);
if(userlist1.size()==1)
if (utype.equals(“注册用户”))
request.getSession(). setAttribute(“username”, userlist1.get(0).get(“yonghuming”));
else
request.getSession(). setAttribute(“username”, userlist1.get(0).get(“gonghao”));
request.getSession(). setAttribute(“cx”, utype);
gor(“index.jsp”, request, response);
}else{
request.setAttribute(“error”, “”);
go(“/index.jsp”, request, response);
if(ac.equals(“adminlogin”))
String username = request.getParameter(“username”);
String password = request.getParameter(“pwd”);
String utype = request.getParameter(“cx”);
String pagerandom = request.getParameter(“pagerandom”)==null?“”:request.getParameter(“pagerandom”);
String random = (String)request.getSession().getAttribute(“random”);
if(!pagerandom.equals(random)&&request.getParameter(“a”)!=null)
request.setAttribute(“random”, “”);
go(“/login.jsp”, request, response);
else{
String sql1=“”;
if (utype.equals(“管理员”))
sql1 = “select * from allusers where username='”+username+“’ and pwd='”+password+"’ ";
if (utype.equals(“站点管理员”))
sql1 = “select * from zhandianguanliyuan where yonghuming='”+username+“’ and mima='”+password+“'”;
List userlist1 = dao.select(sql1);
if(userlist1.size()==1)
if (utype.equals(“管理员”))
request.getSession(). setAttribute(“username”, userlist1.get(0).get(“username”));
request.getSession(). setAttribute(“cx”, userlist1.get(0).get(“cx”));
if (utype.equals(“站点管理员”))
request.getSession(). setAttribute(“username”, userlist1.get(0).get(“yonghuming”));
request.getSession(). setAttribute(“zd”, userlist1.get(0).get(“zulinzhandian”));
request.getSession(). setAttribute(“cx”,utype );
gor(“main.jsp”, request, response);
}else{
request.setAttribute(“error”, “”);
go(“/login.jsp”, request, response);
//修改密码
if(ac.equals(“uppass”))
String olduserpass = request.getParameter(“ymm”);
String userpass = request.getParameter(“xmm1”);
String copyuserpass = request.getParameter(“xmm2”);
HashMap m = dao.getmaps(“yonghuming”,(String)request.getSession().getAttribute(“username”), “yonghuzhuce”);
if(!(((String)m.get(“mima”)).equals(olduserpass)))
request.setAttribute(“error”, “”);
go(“mod2.jsp”, request, response);
}else{
//String id = (String)user.get(“id”);
String sql = “update yonghuzhuce set mima='”+userpass+“’ where yonghuming='”+(String)request.getSession().getAttribute(“username”)+“'”;
dao.commOper(sql);
request.setAttribute(“suc”, “”);
go(“mod2.jsp”, request, response);
//修改密码
if(ac.equals(“adminuppass”))
String olduserpass = request.getParameter(“ymm”);
String userpass = request.getParameter(“xmm1”);
String copyuserpass = request.getParameter(“xmm2”);
//println(Info.getUser(request).get(“id”).toString());
HashMap m = dao.getmaps(“username”,(String)request.getSession().getAttribute(“username”), “allusers”);
if(!(((String)m.get(“pwd”)).equals(olduserpass)))
request.setAttribute(“error”, “”);
go(“mod.jsp”, request, response);
}else{
//String id = (String)user.get(“id”);
String sql = “update allusers set pwd='”+userpass+“’ where username='”+(String)request.getSession().getAttribute(“username”)+“'”;
dao.commOper(sql);
request.setAttribute(“suc”, “”);
go(“mod.jsp”, request, response);
if(ac.equals(“uploaddoc”))
try {
String filename=“”;
request.setCharacterEncoding(“UTF-8”);
RequestContext requestContext = new ServletRequestContext(request);
if(FileUpload.isMultipartContent(requestContext)){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(request.getRealPath(“/upfile/”)+“/”));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(10010241024);
List items = new ArrayList();
items = upload.parseRequest(request);
FileItem fileItem = (FileItem) items.get(0);
if(fileItem.getName()!=null && fileItem.getSize()!=0)
if(fileItem.getName()!=null && fileItem.getSize()!=0){
File fullFile = new File(fileItem.getName());
filename = Info.generalFileName(fullFile.getName());
File newFile = new File(request.getRealPath(“/upfile/”)+“/” + filename);
try {
fileItem.write(newFile);
} catch (Exception e) {
e.printStackTrace();
}else{
go(“/js/uploaddoc.jsp?docname=”+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
if(ac.equals(“uploaddoc2”))
try {
String filename=“”;
request.setCharacterEncoding(“UTF-8”);
RequestContext requestContext = new ServletRequestContext(request);
if(FileUpload.isMultipartContent(requestContext)){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(request.getRealPath(“/upfile/”)+“/”));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(10010241024);
List items = new ArrayList();
items = upload.parseRequest(request);
FileItem fileItem = (FileItem) items.get(0);
if(fileItem.getName()!=null && fileItem.getSize()!=0)
if(fileItem.getName()!=null && fileItem.getSize()!=0){
File fullFile = new File(fileItem.getName());
filename = Info.generalFileName(fullFile.getName());
File newFile = new File(request.getRealPath(“/upfile/”)+“/” + filename);
try {
fileItem.write(newFile);
} catch (Exception e) {
e.printStackTrace();
}else{
go(“/js/uploaddoc2.jsp?docname=”+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
if(ac.equals(“uploaddoc3”))
try {
String filename=“”;
request.setCharacterEncoding(“UTF-8”);
RequestContext requestContext = new ServletRequestContext(request);
if(FileUpload.isMultipartContent(requestContext)){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(request.getRealPath(“/upfile/”)+“/”));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(10010241024);
List items = new ArrayList();
items = upload.parseRequest(request);
FileItem fileItem = (FileItem) items.get(0);
if(fileItem.getName()!=null && fileItem.getSize()!=0)
if(fileItem.getName()!=null && fileItem.getSize()!=0){
File fullFile = new File(fileItem.getName());
filename = Info.generalFileName(fullFile.getName());
File newFile = new File(request.getRealPath(“/upfile/”)+“/” + filename);
try {
fileItem.write(newFile);
} catch (Exception e) {
e.printStackTrace();
}else{
go(“/js/uploaddoc3.jsp?docname=”+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
//导excel
if(ac.equals(“importexcel”))
String page = request.getParameter(“page”);
String whzdstr = request.getParameter(“whzdstr”);
String tablename = request.getParameter(“tablename”);
try {
String filename=“”;
request.setCharacterEncoding(“UTF-8”);
RequestContext requestContext = new ServletRequestContext(request);
if(FileUpload.isMultipartContent(requestContext)){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(request.getRealPath(“/upfile/”)+“/”));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(10010241024);
List items = new ArrayList();
items = upload.parseRequest(request);
FileItem fileItem = (FileItem) items.get(0);
if(fileItem.getName()!=null && fileItem.getSize()!=0)
if(fileItem.getName()!=null && fileItem.getSize()!=0){
File fullFile = new File(fileItem.getName());
filename = Info.generalFileName(fullFile.getName());
File newFile = new File(request.getRealPath(“/upfile/”)+“/” + filename);
try {
fileItem.write(newFile);
} catch (Exception e) {
e.printStackTrace();
}else{
if(filename.indexOf(“.xls”)>-1)
Workbook workbook;
try {
workbook = Workbook.getWorkbook(new File(request.getRealPath(“/upfile/”)+“/”+filename));
//通过Workbook的getSheet方法选择第一个工作簿(从0开始)
Sheet sheet = workbook.getSheet(0);
//通过Sheet方法的getCell方法选择位置为C2的单元格(两个参数都从0开始)
//int empty = 0;
for(int i=1;i<1000;i++)
Cell cell = null;
try{
String isql = “insert into “+tablename+”(”;
for(String str:whzdstr.split(“-”))
isql+=str+“,”;
isql = isql.substring(0,isql.length()-1);
isql+=“)values(”;
int j=0;
int empty = 1;
for(String str:whzdstr.split(“-”))
cell = sheet.getCell(j,i);
isql+=“'”+cell.getContents()+“',”;
String content = cell.getContents()==null?“”:cell.getContents();
if(!“”.equals(content.trim()))
empty = 0;
j++;
if(empty==1)continue;
isql = isql.substring(0,isql.length()-1);
isql+=“)”;
dao.commOper(isql);
}catch (Exception e) {
continue;
workbook.close();
} catch (Exception e) {
e.printStackTrace();
go(“/admin/”+page+“?docname=”+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
if(ac.equals(“uploadimg”))
try {
String filename=“”;
request.setCharacterEncoding(“UTF-8”);
RequestContext requestContext = new ServletRequestContext(request);
if(FileUpload.isMultipartContent(requestContext)){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(request.getRealPath(“/upfile/”)+“/”));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(10010241024);
List items = new ArrayList();
items = upload.parseRequest(request);
FileItem fileItem = (FileItem) items.get(0);
if(fileItem.getName()!=null && fileItem.getSize()!=0)
if(fileItem.getName()!=null && fileItem.getSize()!=0){
File fullFile = new File(fileItem.getName());
filename = Info.generalFileName(fullFile.getName());
File newFile = new File(request.getRealPath(“/upfile/”)+“/” + filename);
try {
fileItem.write(newFile);
} catch (Exception e) {
e.printStackTrace();
}else{
go(“/js/uploadimg.jsp?filename=”+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
if(ac.equals(“uploadimg2”))
try {
String filename=“”;
request.setCharacterEncoding(“UTF-8”);
RequestContext requestContext = new ServletRequestContext(request);
if(FileUpload.isMultipartContent(requestContext)){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(request.getRealPath(“/upfile/”)+“/”));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(10010241024);
List items = new ArrayList();
items = upload.parseRequest(request);
FileItem fileItem = (FileItem) items.get(0);
if(fileItem.getName()!=null && fileItem.getSize()!=0)
if(fileItem.getName()!=null && fileItem.getSize()!=0){
File fullFile = new File(fileItem.getName());
filename = Info.generalFileName(fullFile.getName());
File newFile = new File(request.getRealPath(“/upfile/”)+“/” + filename);
try {
fileItem.write(newFile);
} catch (Exception e) {
e.printStackTrace();
}else{
go(“/js/uploadimg2.jsp?filename=”+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
if(ac.equals(“uploadimg3”))
try {
String filename=“”;
request.setCharacterEncoding(“UTF-8”);
RequestContext requestContext = new ServletRequestContext(request);
if(FileUpload.isMultipartContent(requestContext)){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(request.getRealPath(“/upfile/”)+“/”));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(10010241024);
List items = new ArrayList();
items = upload.parseRequest(request);
FileItem fileItem = (FileItem) items.get(0);
if(fileItem.getName()!=null && fileItem.getSize()!=0)
if(fileItem.getName()!=null && fileItem.getSize()!=0){
File fullFile = new File(fileItem.getName());
filename = Info.generalFileName(fullFile.getName());
File newFile = new File(request.getRealPath(“/upfile/”)+“/” + filename);
try {
fileItem.write(newFile);
} catch (Exception e) {
e.printStackTrace();
}else{
go(“/js/uploadimg3.jsp?filename=”+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
if(ac.equals(“uploadimg4”))
try {
String filename=“”;
request.setCharacterEncoding(“UTF-8”);
RequestContext requestContext = new ServletRequestContext(request);
if(FileUpload.isMultipartContent(requestContext)){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(request.getRealPath(“/upfile/”)+“/”));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(10010241024);
List items = new ArrayList();
items = upload.parseRequest(request);
FileItem fileItem = (FileItem) items.get(0);
if(fileItem.getName()!=null && fileItem.getSize()!=0)
if(fileItem.getName()!=null && fileItem.getSize()!=0){
File fullFile = new File(fileItem.getName());
filename = Info.generalFileName(fullFile.getName());
File newFile = new File(request.getRealPath(“/upfile/”)+“/” + filename);
try {
fileItem.write(newFile);
} catch (Exception e) {
e.printStackTrace();
}else{
go(“/js/uploadimg4.jsp?filename=”+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
if(ac.equals(“uploadimg5”))
try {
String filename=“”;
request.setCharacterEncoding(“UTF-8”);
RequestContext requestContext = new ServletRequestContext(request);
if(FileUpload.isMultipartContent(requestContext)){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(request.getRealPath(“/upfile/”)+“/”));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(10010241024);
List items = new ArrayList();
items = upload.parseRequest(request);
FileItem fileItem = (FileItem) items.get(0);
if(fileItem.getName()!=null && fileItem.getSize()!=0)
if(fileItem.getName()!=null && fileItem.getSize()!=0){
File fullFile = new File(fileItem.getName());
filename = Info.generalFileName(fullFile.getName());
File newFile = new File(request.getRealPath(“/upfile/”)+“/” + filename);
try {
fileItem.write(newFile);
} catch (Exception e) {
e.printStackTrace();
}else{
go(“/js/uploadimg5.jsp?filename=”+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
dao.close();
out.flush();
out.close();
public void init() throws ServletException {
// Put your code here
上传照片管理控制层:
public class Upload extends HttpServlet {
/**
• Constructor of the object.
*/
public Upload() {
super();
/**
• Destruction of the servlet. 
*/
public void destroy() {
super.destroy(); // Just puts “destroy” string in log
// Put your code here
/**
• The doGet method of the servlet. 
• This method is called when a form has its tag value method equals to get.
• @param request the request send by the client to the server
• @param response the response send by the server to the client
• @throws ServletException if an error occurred
• @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
/**
• The doPost method of the servlet. 
• This method is called when a form has its tag value method equals to post.
• @param request the request send by the client to the server
• @param response the response send by the server to the client
• @throws ServletException if an error occurred
• @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
StringBuffer sb = new StringBuffer(50);
response.setContentType(“application/x-msdownload;charset=GB2312”);
try {
response.setHeader(“Content-Disposition”, new String(sb.toString()
.getBytes(), “ISO8859-1”));
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
String filename = request.getParameter(“filename”);
if (request.getHeader(“User-Agent”).toLowerCase().indexOf(“firefox”) > 0){
try {
filename = new String(filename.getBytes(“UTF-8”), “ISO8859-1”);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
else
if (request.getHeader(“User-Agent”).toUpperCase().indexOf(“MSIE”) > 0){
try {
filename = URLEncoder.encode(filename, “UTF-8”);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
response.setContentType(“text/plain”);
response.setHeader(“Location”,filename);
response.reset();
response.setHeader(“Cache-Control”, “max-age=0” );
response.setHeader(“Content-Disposition”, “attachment; filename=” + filename);
try {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
OutputStream fos = null;
// File f = new File(request.getRealPath(“/upfile/”)+“/”+filename);
//System.out.println(f);
bis = new BufferedInputStream((InputStream)new FileInputStream(request.getRealPath(“/upfile/”)+“/”+filename));
fos = response.getOutputStream();
bos = new BufferedOutputStream(fos);
int bytesRead = 0;
byte[] buffer = new byte[5 * 1024];
while ((bytesRead = bis.read(buffer)) != -1) {
bos.write(buffer, 0, bytesRead);
bos.close();
bis.close();
fos.close();
new Info().delPic(request.getRealPath(“/upfile/”)+“/”, filename);
} catch (Exception e) {
}finally{
/**
• Initialization of the servlet. 
• @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here

验证码管理控制层:

public class QRCode extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding(“utf-8”);
response.setCharacterEncoding(“utf-8”);
String website = request.getParameter(“website”);
try {
QRCodeUtil.genGR(website, response.getOutputStream());
} catch (WriterException e) {
e.printStackTrace();
//String website = request.getAttribute(“website”).toString();
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);

java自行车尺码在哪里 java自行车官网报价_java_08