jdk1.8 + tomcat8.5 + mysql + eclispe(intellij idea,eclispe,myeclispe,sts都支持)
springboot+ springmvc + jpa+ jsp + html+ javascript + jquery + ajax + maven等等
订单服务:
@webrvlet("/order/orderrvlet")public class orderrvlet extends httprvlet {private orderrvice rvice = new orderrviceimpl();private clientrviceimpl clientrvice=new clientrviceimpl();@overrideprotected void doget(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {req.tcharacterencoding("utf-8");resp.tcontenttype("text/html;chart=utf-8");string op = req.getparameter("op");// 得到传过来的请求// 生成订单if (op.equals("genorder")) {genorder(req, resp);}// 查看订单if (op.equals("findallorders")) {findallorders(req, resp);}// 管理员查看订单if (op.equals("findorders")) {findorders(req, resp);}// 发货if (op.equals("fahuo")) {fahuo(req, resp);}//删除订单if(op.equals("deletes")) {deletes(req,resp);}} private void deletes(httprvletrequest req, httprvletrespon resp) throws ioexception {string ordernumber = req.getparameter("ordernum");order findorderbynum = rvice.findorderbynum(ordernumber);if(findorderbynum.getitems().size()!=0) {resp.getwriter().print("<script>alert('该订单下有订单子项不可删除,请先删除订单子项!')</script>");resp.getwriter().print("<script>location.href='../admin/managerorder.jsp'</script>");return;}try {rvice.deletebynumber(ordernumber);resp.getwriter().print("<script>alert('删除成功!')</script>");resp.ndredirect("../admin/managerorder.jsp");}catch (exception e) {resp.getwriter().print("<script>alert('该订单下有订单子项不可删除,请先删除订单子项!')</script>");return;}}private void fahuo(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {string ordernum = req.getparameter("ordernum");rvice.fahuo(ordernum);list<order> orders = rvice.findorders();httpssion ssion = req.getssion();ssion.tattribute("orders", orders);system.out.println(orders);resp.ndredirect(req.getcontextpath() + "/admin/managerorder.jsp");} private void findorders(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {list<order> orders = rvice.findorders();httpssion ssion = req.getssion();ssion.tattribute("orders", orders);req.getrequestdispatcher("/admin/managerorder.jsp").forward(req, resp);} private void findallorders(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {httpssion ssion = req.getssion();ur ur = (ur) ssion.getattribute("ur");list<order> orders = rvice.findurorders(ur);req.tattribute("orders", orders);req.getrequestdispatcher("/person/personorder.jsp").forward(req, resp);} private void genorder(httprvletrequest req, httprvletrespon resp) throws ioexception, rvletexception {// 取出购物车信息// 取出购物项信息httpssion ssion = req.getssion();cart cart = (cart) ssion.getattribute("cart");ur ur = (ur) ssion.getattribute("ur");if (cart == null) {ssion.tattribute("message", "会话已经结束!");req.getrequestdispatcher("../message.jsp").forward(req, resp);return;}//先判断库存够不够!book book = cart.getbook();string book_id = book.getbook_id();book findbookbyid = clientrvice.findbookbyid(book_id);if(findbookbyid.getbook_kunumber()-cart.gettotalquantity()<0) {ssion.tattribute("message", "库存不足,无法购买!");ssion.removeattribute("cart");req.getrequestdispatcher("../message.jsp").forward(req, resp);return;}order order = new order();order.ttime(new simpledateformat("yyyy-mm-dd hh:mm:ss").format(new date()));string ordernum = genordernum();order.tordernum(ordernum);order.tquantity(cart.gettotalquantity());order.tmoney(cart.gettotalmoney());order.tur(ur);// 订单项list<orderitem读书内容> oitems = new arraylist<orderitem>();for (map.entry<string, cartitem> me : cart.getitmes().entryt()) {cartitem citem = me.getvalue();orderitem oitem = new orderitem();oitem.tid(genordernum());oitem.tbook(citem.getbook());oitem.tprice(citem.getmoney());oitem.tquantity(citem.getquantity());oitem.tordernum(ordernum);oitems.add(oitem);}// 建立订单项和订单的关系order.titems(oitems);rvice.genorder(order);req.tattribute("order", order);req.getssion().removeattribute("cart");req.removeattribute("cart");req.getrequestdispatcher("/order.jsp").forward(req, resp);} // 生成订单号private string genordernum() {date now = new date();dateformat df = new simpledateformat("yyyymmdd");string s1 = df.format(now);return s1 + system.nanotime();} @overrideprotected void dopost(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {doget(req, resp);}}
管理员登录服务:
@webrvlet("/admin/managerrvlet")public class managerrvlet extends httprvlet {private managerrvice rvice = new managerrviceimpl();@overrideprotected void doget(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {req.tcharacterencoding("utf-8");resp.tcontenttype("text/html;chart=utf-8");string op = req.getparameter("op");// 得到传过来的请求// 管理员登陆if (op.equals("login")) {login(req, resp);}// 修改管理员资料if (op.equals("managerinformation")) {managerinformation(req, resp);}// 修改管理员登录密码if (op.equals("managerpassword")) {managerpassword(req, resp);}// 注销if (op.equals("layout")) {layout(req, resp);}// 添加书籍前先获取所有分类if (op.equals("addbookui")) {addbookui(req, resp);}// 添加书籍if (op.equals("addbook")) {try {addbook(req, resp);} catch (fileuploadexception e) {// todo auto-generated catch blocke.printstacktrace();}}// 添加书籍分类if (op.equals("addcategory")) {addcategory(req, resp);}// 文学艺术类书籍列表if (op.equals("category")) {getcategorybook(req, resp);}// 编辑书籍信息前获取书籍的信息回显if (op.equals("editbookui")) {editbookui(req, resp);}// 编辑书籍if (op.equals("editbook")) {try {editbook(req, resp);} catch (fileuploadexception e) {// todo auto-generated catch blocke.printstacktrace();}}// 删除书籍if (op.equals("delbook")) {delbook(req, resp);}// 获取书籍分类列表if (op.equals("categorylist"))琵琶行 {categorylist(req, resp);}// 获得分类信息if (op.equals("editcategoryui")) {editcategoryui(req, resp);}// 修改书籍分类信息if (op.equals("editcategory")) {editcategory(req, resp);}// 删除书籍分类if (op.equals("delcategory")) {delcategory(req, resp);}// 用户信息管理if (op.equals("findurs")) {findurs(req, resp);}// 添加工作人员if (op.equals("addadmin")) {addadmin(req, resp);}// 书籍销售情况if (op.equals("sales")) {sales(req, resp);}//搜索if(op.equals("arch")) {arch(req,resp);}}private void arch(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {string name = req.getparameter("arch");if(name==null) {name="";}list<book> findlistbybookname = rvice.findlistbybookname(name);list<category> categorylist = rvice.findallcategory();// 分类req.tattribute("currentname", name);req.tattribute("books", findlistbybookname);req.tattribute("categorylist", categorylist);req.getrequestdispatcher("/admin/bookslist.jsp").forward(req, resp);}private void sales(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {list<book> sales = rvice.sales();req.tattribute("sales", sales);req.getrequestdispatcher("/admin/sales.jsp").forward(req, resp);}private void addadmin(httprvletrequest req, httprvletrespon resp) throws ioexception {string urname = req.getparameter("urname");string password = req.getparameter("password");string name = req.getparameter("name");string x = req.getparameter("x");string tel = req.getparameter("tel");administrator admin = new administrator(urname, password, name, x, tel);rvice.addadmin(admin);resp.getwriter().write("<div style='text-align: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>添加成功!</div>");}private void findurs(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {list<ur> list = rvice.findurs();httpssion ssion = req.getssion();ssion.tattribute("urs", list);req.getrequestdispatcher("/admin/managerurs.jsp").forward(req, resp);}private void login(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {string urname = req.getparameter("urname");string password = req.getparameter("password");if(urname==null || urname=="") {req.tattribute("message", "请填写用户名");req.getrequestdispatcher("/admin/404.jsp").forward(req, resp);return;}if(password==null || password=="") {req.tattribute("message", "请填写密码");req.getrequestdispatcher("/admin/404.jsp").forward(req, resp);return;}httpssion ssion = req.getssion();administrator admin = rvice.login(urname, password);if (admin.geturname() != null && admin.geturname() != "") {req.tattribute("message", "登陆成功");ssion.tattribute("admin", admin);req.getrequestdispatcher("/admin/message.jsp").forward(req, resp);} el {req.tattribute("message", "账号或密码错误!");req.getrequestdispatcher("/admin/404.jsp").forward(req, resp);}}private void managerinformation(httprvletrequest req, httprvletrespon resp) throws ioexception {string urname = req.getparameter("urname");string name = req.getparameter("name");string x = req.getparameter("x");string tel = req.getparameter("tel");rvice.managerinformation(urname, name, x, tel);httpssion ssion = req.getssion();administrator admin = (administrator) ssion.getattribute("admin");admin.tname(name);admin.tx(x);admin.ttel(tel);ssion.tattribute("admin", admin);resp.getwriter().write("<div style='text-ali个人建议gn: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>修改成功!</div>");}//修改管理员密码private void managerpassword(httprvletrequest req, httprvletrespon resp) throws ioexception {string urname = req.getparameter("urname");string password = req.getparameter("password");string repassword = req.getparameter("repassword");string oldpassword = req.getparameter("oldpassword");if(!password.equals(repassword)) {resp.getwriter().print("<script>alert('两次密码不一致')</script>");return;}administrator admin = rvice.findadminbyurname(urname);if(!admin.getpassword().equals(oldpassword)) {resp.getwriter().print("<script>alert('旧密码填写错误!')</script>");return;}rvice.managerpassword(urname, password);resp.getwriter().write("<div style='text-align: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>修改成功!</div>");}private void layout(httprvletrequest req, httprvletrespon resp) {try {httpssion ssion = req.getssion();ssion.removeattribute("admin");resp.ndredirect("../admin/managerlogin.jsp");} catch (exception e) {e.printstacktrace();}}private void addbookui(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {list<category> categorys = rvice.findallcategory();req.tattribute("cs", categorys);req.getrequestdispatcher("/admin/addbook.jsp").forward(req, resp);}private void addbook(httprvletrequest req, httprvletrespon resp) throws fileuploadexception, ioexception {// 判断表单是不是multipart/form-data类型boolean ismultipart = rvletfileupload.ismultipartcontent(req);if (!ismultipart) {throw new runtimeexception("表单上传类型有误!!");}// 创建工厂用来 解析请求内容diskfileitemfactory factory = new diskfileitemfactory();// 构建核心类对象rvletfileupload sfu = new rvletfileupload(factory);list<fileitem> items = new arraylist<fileitem>();items = sfu.parrequest(req);book book = new book();for (fileitem item : items) {if (item.isformfield()) {// 普通字段:把数据分装到book对象中processformfield(item, req, book);} el {// 上传字段:上传processuplodfiled(item, req, book);}}// 把书籍信息保存到数据库中rvice.addbook(book);resp.getwriter().write("<div style='text-align: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>添加成功!</div>");}// 处理文件上传private void processuplodfiled(fileitem item, httprvletrequest req, book book) {try {// 存放路径:不要放在web-inf中// 01.获取存放文件的真实目录// string dirimages = getrvletcontext().getrealpath("/images");string dirimages =req.getrvletcontext().getrealpath("/")+"images/";// string dirimages = getrvletcontext().getrealpath("/img");// 02. 通过io存文件// 03. 生成文件名 (用户上传图片, 图片名可能重复)string fieldname = item.getfieldname();// 输入框的name值string name = item.getname();string filetype = name.substring(name.lastindexof(".") + 1);string filename = uuid.randomuuid().tostring();// 生成用不重复的文件名// 生成文件夹名date time = new date();simpledateformat simpledateformat = new simpledateformat("yyyy-mm-dd");string strtime = simpledateformat.format(time);// path属性filenamestring path = strtime +file.parator + "books";// 存放到book对象中的路径// string path = "books";// 存放到book对象中string filename = filename + "." + filetype;// filedir:图片最终存在于filedirfile filedir = new file(dirimages, path + file.parator + filename);// inputstream inputstream = item.getinputstream(); 从请求 对象中 通过流的方式// 把 上传的文件加载到 内存中 构建输出流file parentdir = new file(dirimages, path);// 父目录if (!parentdir.exists()) {parentdir.mkdirs();}book.tfilename(filename);book.tpath(path);inputstream inputstream = item.getinputstream();fileoutputstream fos = new fileoutputstream(filedir);int len = 0;while ((len = inputstream.read()) != -1) {fos.write(len);}} catch (ioexception e) {e.printstacktrace();}}// 把fielditem中的数据封装到book中private void processformfield(fileitem item, httprvletrequest req, book book) {try {// item每一个item对象代表一个输入框// 01. 获取input输入框的 name 的值 根据规范 输入框 的name的取值, 与 javabean 中的 属性名一致string inputname = item.getfieldname();string inputvalue = item.getstring("utf-8");if (inputname.equals("categoryid")) {// 分类单独处理// 获取到选择的分类的id,根据这个id取到分类的信息string categoryid = item.getstring();system.out.println("categoryid=" + categoryid);category category = rvice.findcategorybyid(categoryid);system.out.println(category);book.tcategory(category);} el {beanutils.tproperty(book, inputname, inputvalue);}} catch (exception e) {e.printstacktrace();}}// 添加书籍分类private void addcategory(httprvletrequest req, httprvletrespon resp) {try {category category = new category();beanutils.populate(category, req.getparametermap());string categoryname = category.getcategory_name();if(stringutils.isnullorempty(categoryname)) {resp.getwriter().print("<script>alert('请填写分类名称')</script>");resp.getwriter().print("<script>location.href='../admin/addcategory.jsp'</script>");return;}rvice.addcategory(category);// 调用添加方法resp.getwriter().write("<div style='text-align: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>添加成功!</div>");} catch (exception e) {e.printstacktrace();}}private void getcategorybook(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {list<book> books = rvice.getcategorybook(req.getparameter("cid"));// 文学艺术类书籍list<category> categorylist = rvice.findallcategory();// 分类req.tattribute("books", books);req.tattribute("categorylist", categorylist);req.tattribute("currentname", "");req.getrequestdispatcher("/admin/bookslist.jsp").forward(req, resp);}private void editbookui(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {string book_id = req.getparameter("book_id");book book = findbookbyid(book_id);list<category> category = rvice.findallcategory();hashmap map = new hashmap();map.put("book", book);map.put("category", category);req.tattribute("map", map);req.getrequestdispatcher("/admin/editbook.jsp").forward(req, resp);}private void editbook(httprvletrequest req, httprvletrespon resp) throws fileuploadexception, ioexception {string book_id = req.getparameter("book_id");string book_name = req.getparameter("book_name");string book_author = req.getparameter("book_author");string book_press = req.getparameter("book_press");string book_desc = req.getparameter("book_desc");double book_price = double.pardouble(req.getparameter("book_price"));string book_kunumber = req.getparameter("book_kunumber");string categoryid = req.getparameter("categoryid");category findcategorybyid = rvice.findcategorybyid(categoryid);rvice.editbook(book_id, book_name, book_author, book_press, book_desc, book_price, book_kunumber,findcategorybyid);resp.getwriter().write("<div style='text-align: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>修改成功!</div>");}private void delbook(httprvletrequest req, httprvletrespon resp) throws ioexception {string book_id = req.getparameter("book_id");rvice.delbook(book_id);resp.getwriter().write("<div style='text-align: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>删除成功!</div>");}private void categorylist(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {list<category> categorylist = rvice.findallcategory();req.tattribute("categorylist", categorylist);req.getrequestdispatcher("/admin/categoryslist.jsp").forward(req, resp);}private void editcategoryui(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {category category = rvice.findcategorybyid(req.getparameter("category_id"));req.tattribute("category", category);req.getrequestdispatcher("/admin/editcategory.jsp").forward(req, resp);}private void editcategory(httprvletrequest req, httprvletrespon resp) throws ioexception {category category = new category(req.getparameter("category_id"), req.getparameter("category_name"),req.getparameter("category_desc"));string categoryname = category.getcategory_name();if(stringutils.isnullorempty(categoryname)) {resp.getwriter().print("<script>alert('请填写分类名称')</script>");resp.getwriter().print("<script>location.href='../admin/editcategory.jsp'</script>");return;}rvice.editcategory(category);resp.getwriter().write("<div style='text-align: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>修改成功!</div>");}private void delcategory(httprvletrequest req, httprvletrespon resp) throws ioexception {string category_id = req.getparameter("category_id");rvice.delcategory(category_id);resp.getwriter().write("<div style='text-align: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>删除成功!</div>");}// 通过书籍id找到书籍信息private book findbookbyid(string book_id) {return rvice.findbookbyid(book_id);}@overrideprotected void dopost(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {doget(req, resp);}}
收藏夹业务处理:
@webrvlet("/client/clientrvlet")public class clientrvlet extends httprvlet {private clientrvice rvice = new clientrviceimpl();private managerrvice managerrvice = new managerrviceimpl();@overrideprotected void doget(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {req.tcharacterencoding("utf-8");resp.tcontenttype("text/html;chart=utf-8");string op = req.getparameter("op");// 得到传过来的请求if (op != null && !op.equals("")) {本质特征// 登录if (op.equals("login")) {login(req, resp);}// 注销if (op.equals("layout")) {layout(req, resp);}// 注册if (op.equals("register")) {register(req, resp);}// 文学艺术类书籍列表if (op.equals("category")) {getcategorybook(req, resp);}// 个人信息修改if (op.equals("personinformation")) {personinformation(req, resp);}// 修改密码if (op.equals("personpassword")) {personpassword(req, resp);}// 搜索框if (op.equals("arch")) {arch(req, resp);}// 详情页面if (op.equals("particulars")) {particulars(req, resp);}// 添加购物车if (op.equals("addcart")) {addcart(req, resp);}// 删除购物车中的购物项if (op.equals("delitem")) {delitem(req, resp);}// 修改购物项数量if (op.equals("changenum")) {changenum(req, resp);}// 添加收藏夹if (op.equals("addfavorite")) {addfavorite(req, resp);}// 显示收藏夹if (op.equals("showfavorite")) {showfavorite(req, resp);}// 删除收藏夹if (op.equals("delfavorite")) {delfavorite(req, resp);}// 删除收藏夹if (op.equals("buynow")) {bunow(req, resp);}}}private void delfavorite(httprvletrequest req, httprvletrespon resp) throws ioexception, rvletexception {string book_id = req.getparameter("book_id");rvice.delfavorite(book_id);httpssion ssion = req.getssion();list<favorite> lists = (list<favorite>) ssion.getattribute("favorite");iterator<favorite> iterator = lists.iterator();while (iterator.hasnext()) {favorite favorite = iterator.next();if (book_id.equals(favorite.getbook().getbook_id())) {iterator.remove();// 使用迭代器的删除方法删除}}resp.ndredirect(req.getcontextpath() + "/favorite.jsp");}private void showfavorite(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {httpssion ssion = req.getssion();ur ur = (ur) ssion.getattribute("ur");list<favorite> favorites = rvice.findfavoritebyurid(ur);ssion.tattribute("favorite", favorites);req.getrequestdispatcher("/favorite.jsp").forward(req, resp);}private void addfavorite(httprvletrequest req, httprvletrespon resp) throws ioexception {httpssion ssion = req.getssion();ur ur = (ur) ssion.getattribute("ur");string ur_id = ur.getid();string book_id = req.getparameter("book_id");boolean ixit = rvice.findfavorite(ur_id, book_id);if (ixit == fal) {rvice.addfavorite(ur_id, book_id);}}private void changenum(httprvletrequest req, httprvletrespon resp) throws ioexception {string num = req.getparameter("num");string book_id = req.getparameter("book_id");// 取出购物车cart cart = (cart) req.getssion().getattribute("cart");cartitem item = cart.getitmes().get(book_id);item.tquantity(integer.parint(num));resp.ndredirect(req.getcontextpath() + "/showcart.jsp");}private void login(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {string urname = req.getparameter("urname");string password = req.getparameter("password");httpssion ssion = req.getssion();ur ur = rvice.login(urname, password);if (ur.geturname() != null && ur.geturname() != "") {req.tattribute("message", "登陆成功");ssion.tattribute("ur", ur);req.getrequestdispatcher("/message.jsp").forward(req, resp);} el {req.tattribute("message", "用户名或密码错误,请重新登录");req.getrequestdispatcher("/message.jsp").forward(req, resp);}}private void layout(httprvletrequest req, httprvletrespon resp) {try {httpssion ssion = req.getssion();ssion.removeattribute("ur");// 获取ssion对象,从ssion中移除登陆信息resp.ndredirect("../client/clientrvlet?op=category");} catch (exception e) {e.printstacktrace();}}private void register(httprvletrequest req, httprvletrespon resp) {try {string urname = req.getparameter("urname");string password = req.getparameter("password");string name = req.getparameter("name");string x = req.getparameter("x");string tel = req.getparameter("tel");string address = req.getparameter("address");boolean ixist = fal;// 判断是否存在该用户if (!urname.equals("") && !password.equals("")) {ixist = rvice.register(urname, password, name, x, tel, address);if (ixist == true) {resp.getwriter().print("<script>alert('该用户已经注册,请直接登录')</script>");resp.getwriter().print("<script>location.href='../client/clientrvlet?op=category'</script>");} el {resp.getwriter().write("注册成功!");resp.getwriter().print("<script>location.href='../client/clientrvlet?op=category'</script>");}}el {resp.getwriter().print("<script>alert('请填写账号或密码')</script>");resp.getwriter().print("<script>location.href='../client/clientrvlet?op=category'</script>");}} catch (exception e) {e.printstacktrace();}}private void getcategorybook(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {list<book> books = rvice.getcategorybook(req.getparameter("cid"));// 文学艺术类书籍req.tattribute("books", books);list<category> categorylist= managerrvice.findallcategory();req.tattribute("categorylist", categorylist);req.getrequestdispatcher("/showbook.jsp").forward(req, resp);}private void personinformation(httprvletrequest req, httprvletrespon resp)throws rvletexception, ioexception {string urname = req.getparameter("urname");string name = req.getparameter("name");string x = req.getparameter("x");string tel = req.getparameter("tel");string address = req.getparameter("address");rvice.personinformation(urname, name, x, tel, address);ur ur = (ur) req.getssion().getattribute("ur");ur.turname(urname);ur.tname(name);ur.tx(x);ur.ttel(tel);ur.taddress(address);req.getssion().tattribute("ur", ur);resp.getwriter().write("<div style='text-align: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>修改成功!</div>");}private void personpassword(httprvletrequest req, httprvletrespon resp) throws ioexception {string urname = req.getparameter("urname");string password = req.getparameter("password");string repassword = req.getparameter("repassword");string oldpassword = req.getparameter("oldpassword");if(!repassword.equals(password)) {resp.getwriter().print("<script>alert('两次密码不一致')</script>");}ur ur = rvice.findurbyurname(urname);if(ur==null) {resp.getwriter().print("<script>alert('会话失效或未登录,请重新登录!')</script>");return;}if(!ur.getpassword().equals(oldpassword)) {resp.getwriter().print("<script>alert('旧密码输入错误!')</script>");return;}rvice.personpassword(password, urname);resp.getwriter().write("<div style='text-align: center;margin-top: 260px'><img src='" + req.getcontextpath()+ "/img/duigou.png'/>修改成功!</div>");}private void arch(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {string arch = req.getparameter("arch");list<book> archmessage = rvice.arch(arch);req.tattribute("books", archmessage);req.tattribute("name", arch==null?"":arch);req.getrequestdispatcher("/showbook.jsp").forward(req, resp);}private void particulars(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {string book_id = req.getparameter("book_id");book book = findbookbyid(book_id);req.tattribute("book", book);req.getrequestdispatcher("/particulars.jsp").forward(req, resp);}// 通过书籍id找到书籍信息private book findbookbyid(string book_id) {book book = rvice.findbookbyid(book_id);return book;}private void addcart(httprvletrequest req, httprvletrespon resp) throws ioexception, rvletexception {string book_id = req.getparameter("book_id");book book = findbookbyid(book_id);httpssion ssion = req.getssion();cart cart = (cart) ssion.getattribute("cart");if (cart == null) {cart = new cart();cart.addbook(book);cart.tbook(book);ssion.tattribute("cart", cart);}el {ssion.tattribute("message", "购物车里有商品,请支付之后再来添加!");req.getrequestdispatcher("../message.jsp").forward(req, resp);return;}req.getrequestdispatc男装设计her("../showcart.jsp").forward(req, resp);}private void delitem(httprvletrequest req, httprvletrespon resp) throws ioexception {string book_id = req.getparameter("book_id");cart cart = (cart) req.getssion().getattribute("cart");cart.getitmes().remove(book_id);req.getssion().removeattribute("cart");resp.ndredirect(req.getcontextpath() + "/showcart.jsp");}private void bunow(httprvletrequest req, httprvletrespon resp) throws ioexception, rvletexception {cart cart1 = (cart) req.getssion().getattribute("cart");if(cart1==null) {cart cart = new cart();string book_id = req.getparameter("book_id");book book = findbookbyid(book_id);cart.addbook(book);cart.tbook(book);req.getssion().tattribute("cart", cart);}el {req.getssion().tattribute("message", "购物车里有商品,请支付之后再来添加!");req.getrequestdispatcher("../message.jsp").forward(req, resp);return;}req.getrequestdispatcher("../showcart.jsp").forward(req, resp);}@overrideprotected void dopost(httprvletrequest req, httprvletrespon resp) throws rvletexception, ioexception {doget(req, resp);}}
到此这篇关于java毕业设计实战之图片展览馆管理系统的实现的文章就介绍到这了,更多相关java 图片展览馆管理系统内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!
本文发布于:2023-04-04 18:53:25,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/faf305a3e6f0c44405112e2680604fcb.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:Java毕业设计实战之图片展览馆管理系统的实现.doc
本文 PDF 下载地址:Java毕业设计实战之图片展览馆管理系统的实现.pdf
留言与评论(共有 0 条评论) |