事情来得太忽然,一个朋友说是要我帮忙作一个JavaWeb的课程设计,在过一天就要去答辩了…
这我哪受的了时间这么短尚未~~~,正准备委婉的拒绝的时候他说写完以后给我那个啥…
好吧,我就是这么庸俗php
那好吧,泡杯雀巢(特浓)开工。java
这是我快作完的时候他给他瞧瞧的项目结构,居然看不懂,那就只能改了。
git
这是把一些接口继承干掉以后的目录结构。github
上面就是最后的目录结构,应该很容易理解吧。web
这里描述的是这个项目的关键地方,懂了这里,整个项目就不在话下。sql
最主要的就是那三个servlet,也就是controller类.数据库
这里是 UserServlet.java。tomcat
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { this.doPost(req, resp); } protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String action = req.getParameter("action"); switch (action) { case "adLogin": { // 判断管理员密码是否正确 login(req, resp, 1); } break; case "login": { // 判断用户密码是否正确 login(req, resp, 0); } break; case "loginOut": { // 退出登陆 loginOut(req, resp, 0); } break; case "showAllUsers": { // 显示全部用户 showAllUsers(req, resp); } break; case "delUser": { // 删除用户 delUser(req, resp); } break; case "updateUser": { // 更新 updateUser(req, resp); } break; case "insertUser": { // 插入用户 insertUser(req, resp); } } }
几乎全部有关用户的请求都通过这里,根据传过来的action指令不一样,调用不一样的方法来而后相应的结果或者是页面。服务器
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doPost(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String action = req.getParameter("action"); if (action.equals("showAllIndents")){showAllIndents(req, resp);} else if (action.equals("showAllUserIndents")){showAllUserIndents(req, resp);} else if (action.equals("delIndent")){delIndent(req, resp);} else if (action.equals("payout")){payout(req, resp);} switch (action) { // 显示全部订单 case "showAllIndents": { showAllIndents(req, resp); } break; // 显示全部用户订单 case "showAllUserIndents": { showAllUserIndents(req, resp); } break; // 删除订单 case "delIndent": { delIndent(req, resp); } break; // 支付,等价于生成订单 case "payout": { payout(req, resp); } break; } }
在处理订单和商品的的请求时也是用了一样的道理。接下类的代码就不BB了,能够在GitHub
上取,里面写了我自认为蛮多的代码。jsp
朋友说要作最简单的,那我就作最简单的哦。
这是首页
这里是商品中心也就是用户中心
简单吗
-- phpMyAdmin SQL Dump -- version 4.4.15.10 -- https://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: 2019-06-19 15:15:18 -- 服务器版本: 5.7.19-log -- PHP Version: 5.4.45 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `jsp_shop` -- -- -------------------------------------------------------- -- -- 表的结构 `ad_users` -- CREATE TABLE IF NOT EXISTS `ad_users` ( `id` int(11) NOT NULL, `username` varchar(50) NOT NULL, `password` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- 转存表中的数据 `ad_users` -- INSERT INTO `ad_users` (`id`, `username`, `password`) VALUES (1, 'admin', 'admin'); -- -------------------------------------------------------- -- -- 表的结构 `goods` -- CREATE TABLE IF NOT EXISTS `goods` ( `id` int(11) NOT NULL, `goodsClassId` int(11) NOT NULL, `goodname` varchar(20) NOT NULL, `price` float NOT NULL, `amount` int(11) NOT NULL, `leave_amount` int(11) NOT NULL, `img` varchar(200) DEFAULT NULL ) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8; -- -- 转存表中的数据 `goods` -- INSERT INTO `goods` (`id`, `goodsClassId`, `goodname`, `price`, `amount`, `leave_amount`, `img`) VALUES (4, 1, 'zzz', 43, 0, 54, 'https://img12.360buyimg.com/n7/jfs/t1/63005/7/2162/346204/5d073a88E037d277f/ad359511de220251.jpg'), (6, 1, '阿迪达斯', 499, 100, 13, 'https://img10.360buyimg.com/n7/jfs/t1/19909/3/6832/54742/5c62746fE4ca54219/dd9fd5234e80ca56.jpg'), (8, 2, '男士levis外套', 300, 100, 16, 'https://img13.360buyimg.com/n8/jfs/t1/82625/13/358/355493/5ce8ada3E190147ae/28d18a09922d5084.jpg'), (13, 5, '男士休闲包', 299, 100, 18, 'https://img13.360buyimg.com/n7/jfs/t1/62078/7/1965/323619/5d04b1c2E0270ed58/3bdfde61f9b6abe4.jpg'); -- -------------------------------------------------------- -- -- 表的结构 `goodsclass` -- CREATE TABLE IF NOT EXISTS `goodsclass` ( `id` int(11) NOT NULL, `classname` varchar(30) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; -- -- 转存表中的数据 `goodsclass` -- INSERT INTO `goodsclass` (`id`, `classname`) VALUES (1, '男鞋'), (2, '男士外套'), (5, '男士挎包'); -- -------------------------------------------------------- -- -- 表的结构 `indent` -- CREATE TABLE IF NOT EXISTS `indent` ( `id` int(11) NOT NULL, `indentNo` varchar(20) NOT NULL, `userId` int(11) NOT NULL, `totalPrice` float DEFAULT NULL ) ENGINE=InnoDB AUTO_INCREMENT=76 DEFAULT CHARSET=utf8; -- -- 转存表中的数据 `indent` -- INSERT INTO `indent` (`id`, `indentNo`, `userId`, `totalPrice`) VALUES (72, 'HYD-34-71', 34, NULL), (73, 'HYD-34-72', 34, 123), (74, 'HYD-34-73', 34, 123), (75, 'HYD-34-74', 34, 123); -- -------------------------------------------------------- -- -- 表的结构 `indentlist` -- CREATE TABLE IF NOT EXISTS `indentlist` ( `id` int(11) NOT NULL, `indentId` int(11) NOT NULL, `goodId` int(11) NOT NULL, `amount` int(11) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=74 DEFAULT CHARSET=utf8; -- -- 转存表中的数据 `indentlist` -- INSERT INTO `indentlist` (`id`, `indentId`, `goodId`, `amount`) VALUES (70, 72, 4, 1), (71, 73, 6, 3), (72, 74, 4, 1), (73, 75, 4, 1); -- -------------------------------------------------------- -- -- 表的结构 `users` -- CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL, `username` varchar(20) NOT NULL, `password` varchar(20) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8; -- -- 转存表中的数据 `users` -- INSERT INTO `users` (`id`, `username`, `password`) VALUES (34, '123', '123'), (36, '321', '321'), (38, '543543', '54353475'), (39, '9789', '9879'); -- -- Indexes for dumped tables -- -- -- Indexes for table `goods` -- ALTER TABLE `goods` ADD PRIMARY KEY (`id`); -- -- Indexes for table `goodsclass` -- ALTER TABLE `goodsclass` ADD PRIMARY KEY (`id`); -- -- Indexes for table `indent` -- ALTER TABLE `indent` ADD PRIMARY KEY (`id`); -- -- Indexes for table `indentlist` -- ALTER TABLE `indentlist` ADD PRIMARY KEY (`id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `goods` -- ALTER TABLE `goods` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=21; -- -- AUTO_INCREMENT for table `goodsclass` -- ALTER TABLE `goodsclass` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `indent` -- ALTER TABLE `indent` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=76; -- -- AUTO_INCREMENT for table `indentlist` -- ALTER TABLE `indentlist` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=74; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=40; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;