基于javaweb+mysql的网上书店图书商城(前台、后台)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
前台:登录注册、管理个人信息、修改密码、收藏图书、下单购买
后台:管理个人信息、书籍管理、分类管理、图书管理、订单管理、用户管理、添加管理员,销售统计信息
前台
后台
技术框架
JSP Servlet MySQL JDBC Tomcat CSS JavaScript bootstrap jquery
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
<div class="container-fluid"><div id="carousel-example-generic" class="carousel slide"data-ride="carousel"><!-- 轮播图的中的小点 --><ol class="carousel-indicators"><li data-target="#carousel-example-generic" data-slide-to="0"class="active"></li><li data-target="#carousel-example-generic" data-slide-to="1"></li><li data-target="#carousel-example-generic" data-slide-to="2"></li><li data-target="#carousel-example-generic" data-slide-to="3"></li><li data-target="#carousel-example-generic" data-slide-to="4"></li></ol><!-- 轮播图的轮播图片 --><div class="carousel-inner" role="listbox">
if (op.equals("faHuo")) {faHuo(req, resp);}//删除订单if(op.equals("deletes")) {deletes(req,resp);}}private void deletes(HttpServletRequest req, HttpServletResponse resp) throws IOException {String orderNumber = Parameter("orderNum");Order findOrderByNum = service.findOrderByNum(orderNumber);Items().size()!=0) {Writer().print("<script>alert('该订单下有订单子项不可删除,请先删除订单子项!')</script>");
// 添加到收藏@Overridepublic void addfavorite(String favorite_id, String user_id, String book_id) {try {Connection connection = Connection();PreparedStatement prepareStatement = connection.prepareStatement("insert into favorite (favorite_id,user_id,book_id) values (?,?,?)");prepareStatement.setString(1, favorite_id);prepareStatement.setString(2, user_id);prepareStatement.setString(3, book_id);uteUpdate();} catch (SQLException e) {e.printStackTrace();}}// 根据用户查找收藏
ResultSet rs = uteQuery();while (rs.next()) {Category category = new Category();category.setCategory_String("category_id"));category.setCategory_String("category_name"));category.setCategory_String("category_desc"));list.add(category);}} catch (Exception e) {e.printStackTrace();}return list;}// ͨ跟据分类id查询分类@Overridepublic Category findCategoryById(String categoryid) {Category category = new Category();try {Connection connection = Connection();PreparedStatement prepareStatement = connection.prepareStatement("select * from category where category_id = ?");prepareStatement.setString(1, categoryid);ResultSet rs = uteQuery();if (rs.next()) {category.setCategory_String("category_id"));
}// 编辑书籍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);
prepareStatement.setString(1, Name());prepareStatement.setString(2, Sex());prepareStatement.setString(3, Tel());prepareStatement.setString(4, Address());prepareStatement.setString(5, Username());uteUpdate();} catch (Exception e) {e.printStackTrace();}}// 更新密码操作@Overridepublic void personPassword(User user) {
private void layout(HttpServletRequest req, HttpServletResponse resp) {try {HttpSession session = Session();veAttribute("user");// 获取session对象,从session中移除登陆信息resp.sendRedirect("../client/ClientServlet?op=category");} catch (Exception e) {e.printStackTrace();}}private void register(HttpServletRequest req, HttpServletResponse resp) {try {String username = Parameter("username");String password = Parameter("password");String name = Parameter("name");String sex = Parameter("sex");String tel = Parameter("tel");String address = Parameter("address");boolean isExist = false;// 判断是否存在该用户
e.printStackTrace();}throw new RuntimeException("");}//根据图书id查询private Book findBookById(String book_id) {try {PreparedStatement prepareStatement = connection.prepareStatement("select * from bookdb where book_id=?");prepareStatement.setString(1, book_id);ResultSet rs = uteQuery();Book book = new Book();if (rs.next()) {book.setBook_String("book_id"));book.setBook_String("book_name"));book.setBook_String("book_author"));book.setBook_String("book_press"));Category category = String("book_category"));book.setCategory(category);book.String("filename"));book.String("path"));book.setBook_String("book_desc"));book.setBook_Int("book_kunumber"));book.setBook_Int("book_xiaonumber"));
while (()) {category.setCategory_String("category_id"));category.setCategory_String("category_name"));category.setCategory_String("category_desc"));return category;}} catch (Exception e) {e.printStackTrace();}throw new RuntimeException("查询失败");}// 根据分类查找图书@Override
admin.String("admin_password"));admin.String("admin_name"));admin.String("admin_sex"));admin.String("admin_tel"));}} catch (Exception e) {e.printStackTrace();}return admin;}//根据图书名称模糊查询@Overridepublic List<Book> findListByBookName(String name) {Connection connection = Connection();List<Book> list = new ArrayList<Book>();try {PreparedStatement preparedStatement =connection.prepareStatement("select * from bookdb where book_name like ?");preparedStatement.setString(1, "%"+name+"%");ResultSet rs = uteQuery(); while (rs.next()) {Book books = new Book();books.setBook_String("book_id"));books.setBook_String("book_name"));books.setBook_String("book_author"));books.setBook_String("book_press"));Category category = String("book_category"));books.setCategory(category);
}} catch (Exception e) {e.printStackTrace();}return admin;}// 修改个人信息@Overridepublic void managerInformation(Administrator admin) {try {Connection connection = Connection();PreparedStatement prepareStatement = connection.prepareStatement("update administrator set admin_name=?, admin_sex=?, admin_tel=? where admin_username=? ");prepareStatement.setString(1, Name());prepareStatement.setString(2, Sex());prepareStatement.setString(3, Tel());prepareStatement.setString(4, Username());uteUpdate();
import com.demo.web.formbean.CartItem;@WebServlet("/client/ClientServlet")
public class ClientServlet extends HttpServlet {private ClientService service = new ClientServiceImpl();private ManagerService managerService = new ManagerServiceImpl();@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {req.setCharacterEncoding("UTF-8");resp.setContentType("text/html;charset=UTF-8");String op = Parameter("op");// 得到传过来的请求if (op != null && !op.equals("")) {// 登录if (op.equals("login")) {login(req, resp);
if (!username.equals("") && !password.equals("")) {isExist = ister(username, password, name, sex, tel, address);if (isExist == true) {Writer().print("<script>alert('该用户已经注册,请直接登录')</script>");Writer().print("<script>location.href='../client/ClientServlet?op=category'</script>");} else {Writer().write("注册成功!");Writer().print("<script>location.href='../client/ClientServlet?op=category'</script>");}}else {Writer().print("<script>alert('请填写账号或密码')</script>");Writer().print("<script>location.href='../client/ClientServlet?op=category'</script>");}} catch (Exception e) {e.printStackTrace();}}private void getCategoryBook(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
<spanstyle="font: 700 16px Arial, 'microsoft yahei'; color: #666; padding-top: 10px; line-height: 28px; margin-bottom: 5px; margin-left: 10px">《${book.book_name}》</span></div><!-- 作者出版社 --><div style="margin-left: 18px; margin-top: 15px"><span style="font-size: 5px; color: #1890FF;">${book.book_press}</span> <strong>编</strong> <spanstyle="font-size: 5px; color: #1890FF;">${book.book_author}</span> <strong>著</strong></div><!-- 价格&销量 --><divstyle="margin-top: 20px; margin-left: 18px; width: 620px; height: 270px; background-color: rgb(247, 245, 241)"><img alt="bg——img" src="${tPath}/img/seckilling.png"><div style="margin-top: 20px; margin-left: 30px"><span style="color: rgb(153, 153, 153)">所属分类:</span> ${book.category.category_name}<br><span style="color: rgb(153, 153, 153)">书籍描述:</span><textarea disabled="disabled" class="form-control" rows="3"id="book_desc" name="book_desc" placeholder="${book.book_desc}"style="width: 570px; margin-top: 7px; margin-bottom: 7px"></textarea><span style="color: rgb(153, 153, 153)">书籍单价:</span><spanstyle="font-size: 16px; font-weight: 700; color: #C62E2D"> ¥${book.book_price}</span><br><span style="color: rgb(153, 153, 153)">书籍库存:</span> ${book.book_kunumber} 本<br><span style="color: rgb(153, 153, 153)">书籍销量:</span> ${book.book_xiaonumber} 本<br></div></div><!-- 收藏 -->
return false;}if($("#password").val()!=$("#sub-password").val()){alert("两次密码不一致");return false;}if($('input[type="radio"]:checked').length==0){alert("请选择性别!");return false;}if($("#name").val()==""|| $("#name").val()==null){alert("请填写姓名!");return false;}
*zoom: 1;padding: 4px 10px 4px;margin-bottom: 0;font-size: 13px;line-height: 18px;color: #333333;text-align: center;text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);vertical-align: middle;background-color: #f5f5f5;background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);background-image: -ms-linear-gradient(top, #ffffff, #e6e6e6);background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff),to(#e6e6e6));
本文发布于:2024-02-04 21:59:54,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170717368659985.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |