基于rvlet+jsp+jdbc的后台管理系统,包含5个模块:汽车账户部管理、租车账户部管理、汽车信息管理表、租车记录表、租车租聘表。功能完整,均能实现增删查改。
运行环境: jdk8+tomcat8.5+mysql5.7+eclip
项目技术: rvlet+jsp+jdbc+easyui+jquery
主页登陆注册业务:
public class forervlet extends baforervlet {/*** 显示主页** @param request* @param respon* @param page* @return*/public string home(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了 forervlet home方法");list<category> cs = new categorydao().list();new productdao().fill(cs);new productdao().fillbyrow(cs);request.tattribute("cs", cs);return "home.jsp";}/*** 注册** @param request* @param respon* @param page* @return*/public string register(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了 forervlet register方法");map<string, string> params = new hashmap<>();inputstream inputstream = super.parupload(request, params);system.out.println(params);string name = params.get("name");string password = params.get("password");system.out.println(name);// 判断用户名是否存在boolean exist = urdao.ixists(name);if (exist) {request.tattribute("msg", "用户名已经被使用");return "register.jsp";}ur ur = new ur();ur.tname(name);ur.tpassword(password);system.out.println(ur.getname());system.out.println(ur.getpassword());urdao.add(ur);return "@registersuccess.jsp";}/*** 登录** @param request* @param respon* @param page* @return*/public string login(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了 forervlet login方法");map<string, string> params = new hashmap<>();inputstream inputstream = super.parupload(request, params);system.out.println(params);string name = params.get("name");string password = params.get("password");// 登录ur ur = urdao.get(name, password);if (null == ur) {request.tattribute("msg", "账号密码错误");return "login.jsp";}// 将账号密码储存在ssion中request.getssion().tattribute("ur", ur);return "@forehome";}/*** 登出** @param request* @param respon* @param page* @return*/public string logout(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了 forervlet logout方法");request.getssion().removeattribute("ur");return "@forehome";}/*** 检查用户是否登录** @param request* @param respon* @param page* @return*/public string checklogin(httprvletrequest request, httprvletrespon respon, page page) {ur ur = (ur) request.getssion().getattribute("ur");if (ur != null) {return "%success";}return "%fail";}/*** 模态登录框通过 ajax 方法登录** @param request* @param respon* @param page* @return*/public string loginajax(httprvletrequest request, httprvletrespon respon, page page) {string name = request.getparameter("name");string password = request.getparameter("password");ur ur = urdao.get(name, password);if (ur == nulcf步枪l)return "%fail";request.getssion().tattribute("ur", ur);return "%success";}/*** 显示产品页** @param request* @param respon* @param page* @return*/public string product(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了 forervlet product方法");int pid = integer.parint(request.getparameter("pid"));product p = productdao.get(pid);// 获取产品的single图片和detail图片list<productimage> productsingleimages = productimagedao.list(p, productimagedao.type_single);list<productimage> productdetailimages = productimagedao.list(p, productimag首长秘书edao.type_detail);p.tproductsingleimages(productsingleimages);p.tproductdetailimages(productdetailimages);//p.tfirstproductimage(productsingleimages.get(0));// 获取产品属性信息list<propertyvalue> pvs = propertyvaluedao.list(p.getid());// 获取产品评价信息list<review> reviews = reviewdao.list(p.getid());// 设置产品销量数和评价数productdao.tsaleandreviewnumber(p);request.tattribute("p", p);request.tattribute("pvs", pvs);request.tattribute("reviews", reviews);return "product.jsp";}/*** 分类页面** @return*/public string category(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了forervlet category方法");int cid = integer.parint(request.getparameter("cid"));// 获取分类对象并为填充产品对象、销量、评价category c = new categorydao().get(cid);new productdao().fill(c);new productdao().tsaleandreviewnumber(c.getproducts());// 根据获取的排序方式进行排序string sort = request.getparameter("sort");if (null != sort) {switch (sort) {ca "review":collections.sort(c.getproducts(), new productreviewcomparator());break;ca "date":collections.sort(c.getproducts(), new productdatecomparator());break;ca "salecount":collections.sort(c.getproducts(), new productsalecountcomparator());break;ca "price":collections.sort(c.getproducts(), new productpricecomparator());break;ca "all":collections.sort(c.getproducts(), new productallcomparator());break;}}// 排序完成后,将分类对象添加到域对象 request 中request.tattribute("c", c);return "category.jsp";}/*** 搜索功能** @param request* @param respon* @param page* @return*/public string arch(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了forervlet arch方法");string keyword = request.getparameter("keyword");list<product> ps = null;// 加入异常,防止崩溃try {ps = productdao.arch(keyword, 0, 50);} catch (exception e) {e.printstacktrace();}// 设置产品的销量和评论productdao.tsaleandreviewnumber(ps);request.tattribute("ps", ps);return "archresult.jsp";}/*** 立即购买** @param request* @param respon* @param page* @return*/public string buyone(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了forervlet buyone方法");int pid = integer.parint(request.getparameter("pid"));int num = integer.parint(request.getparameter("num"));product p = productdao.get(pid);ur ur = (ur) request.getssion().getattribute("ur");list<orderitem> ois = orderitemdao.listbyur(ur.getid());int oiid = 0;boolean found = fal;// 遍历订单,如果订单已存在对应的产品,就在对应购物车的基础上调整数量if (null != ois) {for (orderitem oi : ois) {if (oi.getproduct().getid() == p.getid()) {oi.tnumber(oi.getnumber() + num);orderitemdao.update(oi);found = true;oiid = oi.getid();break;}}}// 如果没找到对应的商品,则新建一条订单项if (!found) {orderitem oi = new orderitem();oi.tur(ur);oi.tproduct(p);oi.tnumber(num);orderitemdao.add(oi);oiid = oi.getid();}return "@forebuy?oiid=" + oiid;}/*** 结算页面** @param request* @param respon* @param page* @return*/public string buy(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了forervlet buy方法");string[] oiids = request.getparametervalues("oiid");list<orderitem> ois = new arraylist<>();float total = 0;for (string strid : oiids) {int oiid = integer.parint(strid);orderitem oi = orderitemdao.get(oiid);total += oi.getproduct().getpromoteprice() * oi.getnumber();ois.add(oi);}request.getssion().tattribute("ois", ois);request.tattribute("total", total);return "buy.jsp";}/*** 购物车** @param request* @param respon* @param page* @return*/public string cart(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了forervlet cart方法");ur ur = (ur) request.getssion().getattribute("ur");list<orderitem> ois = orderitemdao.listbyur(ur.getid());request.tattribute("ois", ois);return "cart.jsp";}/*** 加入购物车** @param request* @param respon* @param page* @return*/public string addcart(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了forervlet addcart方法");int pid = integer.parint(request.getparameter("pid"));int num = integer.parint(request.getparameter("num"));product p = productdao.get(pid);ur ur = (ur) request.getssion().getattribute("ur");list<orderitem> ois = orderitemdao.listbyur(ur.getid());int oiid = 0;boolean found = fal;// 遍历订单,如果订单已存在对应的产品,就在对应购物车的基础上调整数量if (null != ois) {for (orderitem oi : ois) {if (oi.getproduct().getid() == p.getid()) {oi.tnumber(oi.getnumber() + num);orderitemdao.update(oi);found = true;oiid = oi.getid();break;}}}// 如果没找到对应的商品,则新建一条订单项if (!found) {orderitem oi = new orderitem();oi.tur(ur);oi.tproduct(p);oi.tnumber(num);orderitemdao.add(oi);oiid = oi.getid();}return "%success";}/*** 更改当前订单项的内容** @param request* @param respon* @param page* @return* @throws unsupportedencodingexception*/public string changeorderitem(httprvletrequest request, httprvletrespon respon, page page) throws unsupportedencodingexception {system.out.println("调用了forervlet changeorderitem方法");ur ur = (ur) request.getssion().getattribute("ur");if (null == ur)return "%fail";int pid = integer.parint(request.getparameter("pid"));int number = integer.parint(request.getparameter("number"));list<orderitem> ois = orderitemdao.listbyur(ur.getid());for (orderitem oi : ois) {if (oi.getproduct().getid() == pid) {oi.tnumber(number);orderitemdao.update(oi);break;}}return "%success";}/*** 删除订单项** @param request* @param respon* @param page* @return* @throws unsupportedencodingexception*/public string deleteorderitem(httprvletrequest request, httprvletrespon respon, page page) throws unsupportedencodingexception {system.out.println("调用了forervlet deleteorderitem方法");ur ur = (ur) request.getssion().getattribute("ur");if (null == ur)return "%fail";int oiid = integer.parint(request.getparameter("oiid"));orderitemdao.delete(oiid);return "%success";}/*** 创建订单** @param request* @param respon* @param page* @return* @throws unsupportedencodingexception*/public string createorder(httprvletrequest request, httprvletrespon respon, page page) throws unsupportedencodingexception {system.out.println("调用了forervlet createorder方法");// 防止post方法中文乱码request.tcharacterencoding("utf-8");ur ur = (ur) request.getssion().getattribute("ur");list<orderitem> ois = (list<orderitem>) request.getssion().getattribute("ois");if (ois.impty())return "@login.jsp";string address = request.getparameter("address");string post = request.getparameter("post");string reciver = request.getparameter("reciver");string mobile = request.getparameter("mobile");order order = new order();string ordercode = new simpledateformat("yyyymmddhhmmss").format(new date());order.tordercode(ordercode);order.taddress(address);order.tpost(post);order.treceiver(reciver);order.tmobile(mobile);order.turmessage("默认内容");order.tcreatedate(new date());order.tur(ur);order.tstatus(orderdao.waitpay);orderdao.add(order);// 统计总金额并设置每个订单项的所属订单float total = 0;for (orderitem oi : ois) {oi.torder(order);orderitemdao.update(oi);total += oi.getproduct().getpromoteprice() * oi.getnumber();}return "@forealipay?oid=" + order.getid() + "&total=" + total;}/*** 支付界面** @param request* @param respon* @param page* @return*/public string alipay(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了forervlet alipay方法");return "alipay.jsp";}/*** 支付完成界面* @param request* @param respon* @param page* @return*/public string payed(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了forervlet payed方法");int oid = integer.parint(request.getparameter("oid"));order order = orderdao.get(oid);order.tstatus(orderdao.waitdelivery);order.tpaydate(new date());orderdao.update(order);request.tattribute("o", order);return "payed.jsp";}/*** 我的订单页面* @param request* @param respon* @param page* @return*/public string bought(httprvletrequest request, httprvletrespon respon, page page) {system.out.println("调用了forervlet bought方法");ur ur = (ur) request.getssion().getattribute("ur");list<order> os = orderdao.list(ur.getid(), orderdao.delete);orderitemdao.fill(os);request.tattribute("os", os);return "bought.jsp";}}
用户登陆页面:
<%@ page contenttype="text/html;chart=utf-8" language="java" %><%@ taglib uri="/d/file/titlepic/" prefix="c"%><!doctype html><html><head><title>用户登录</title><meta name="viewport" content="width=device-width, initial-scale=1"><meta http-equiv="content-type" content="text/html; chart=utf-8"><link type="text/css" rel="stylesheet" href="<%=request.getcontextpath()%>/css/bootstrap.css" rel="external nofollow" ><link type="text/css" rel="stylesheet" href="<%=request.getcontextpath()%>/css/style.css" rel="external nofollow" ><script type="text/javascript" src="<%=reque情侣野外嘿咻st.getcontextpath()%>/js/jquery.min.js"></script><script type="text/javascript" src="<%=request.getcontextpath()%>/js/bootstrap.min.js"></script><script type="text/javascript" src="<%=request.getcontextpath()%>/js/simplecart.min.js"></script></head><body><!--header--><jsp:include page="header.jsp"><jsp:param name="flag" value="9"></jsp:param></jsp:include><!--//header--><!--account--><div class="account"><div class="container"><div class="register"><c:if test="${!empty msg }"><div class="alert alert-success">${msg }</div></c:if><c:if test="${!empty failmsg }"><div class="alert alert-danger">${failmsg }</div></c:if><form action="<%=request.getcontextpath()%>/ur_login" method="post"><div class="register-top-grid"><h3>用户登录</h3><div class="input"><span>用户名/邮箱 <label style="color:red;">*</label></span><input type="text" name="ue" placeholder="请输入用户名" required="required"></div><div class="input"><span>密码 <label style="color:red;">*</label></span><input type="text" name="password" placeholder="请输入密码" required="required"></div><div class="clearfix"> </div></div><div class="register-but text-center"><input type="submit" value="提交"><div class="clearfix"> </div></div></form><div class="clearfix"> </div></div></div></div><!--//account--><!--footer--><jsp:include page="footer.jsp"></jsp:include><!--//footer--></body></html>
添加类型业务:
@webrvlet("/addcategoryrvlet")public class addcategoryrvlet extends httprvlet {protected void dopost(httprvletrequest request, httprvletrespon respon) throws rvletexception, ioexception {request.tcharacterencoding("utf-8");respon.tcharacterencoding("utf-8");string a = request.getparameter("parentid");string b = request.getparameter("classname");system.out.println("parentid"+a);system.out.println("classname"+b);category category = new category();category.tcategor耶酥y_parentid(integer.valueof(a));category.tcategory_name(b);categoryrvice rvice = new categoryrviceimpl();rvice.addcategory(category);printwriter out = respon.getwriter();out.write("<script>");out.write("alert('插入分类成功!');");out.write("location.href='/homeecms/categorylistrvlet'");out.write("</script>");out.clo();// request.getrequestdispatcher("").forward(request,respon);}protected void doget(httprvletrequest request, httprvletrespon respon) throws rvletexception, ioexception {dopost(request,respon);}}
到此这篇关于java毕业设计实战之共享租车信息管理系统的扬起理想的风帆实现的文章就介绍到这了,更多相关java 共享租车信息管理内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!
本文发布于:2023-04-04 21:57:47,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/a17fde927ea62c12c39eb269df4f54ad.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:Java毕业设计实战之共享租车信息管理系统的实现.doc
本文 PDF 下载地址:Java毕业设计实战之共享租车信息管理系统的实现.pdf
留言与评论(共有 0 条评论) |