From 241e9431608580f7bcc79499a15d765a4fab3f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90inh=20Qu=E1=BB=91c=20Ch=C6=B0=C6=A1ng?= Date: Fri, 1 Mar 2024 07:53:47 +0700 Subject: [PATCH] fix err 404 and set constrain for list product --- .../management/product/ProductServlet.java | 10 +- .../view/jsp/management/product/product.jsp | 109 ++++++++++-------- 2 files changed, 68 insertions(+), 51 deletions(-) diff --git a/src/main/java/io/hardingadonis/saledock/controller/management/product/ProductServlet.java b/src/main/java/io/hardingadonis/saledock/controller/management/product/ProductServlet.java index c678656..9095ddf 100644 --- a/src/main/java/io/hardingadonis/saledock/controller/management/product/ProductServlet.java +++ b/src/main/java/io/hardingadonis/saledock/controller/management/product/ProductServlet.java @@ -23,13 +23,21 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) int limit = 10; if (request.getParameter("page") != null) { - page = Integer.parseInt(request.getParameter("page")); + try { + page = Integer.parseInt(request.getParameter("page")); + + } catch (Exception e) { + response.sendRedirect("./error-404"); + return; + } } List list = Singleton.productDAO.pagination((page - 1) * limit, limit); Integer count = Singleton.productDAO.count(); int totalPage = Singleton.productDAO.totalPages(limit); + list.isEmpty(); + request.setAttribute("productList", list); request.setAttribute("currentPage", page); request.setAttribute("totalPage", totalPage); diff --git a/src/main/webapp/view/jsp/management/product/product.jsp b/src/main/webapp/view/jsp/management/product/product.jsp index 0f1cb0f..1cbefb4 100644 --- a/src/main/webapp/view/jsp/management/product/product.jsp +++ b/src/main/webapp/view/jsp/management/product/product.jsp @@ -28,62 +28,71 @@

Quản lý sản phẩm

Thêm sản phẩm -
-
- - - - - - - - - - - + +
+
+
Mã sản phẩmTên sản phẩmPhân loạiThao tác
+ - - - - + + + + - - -
${product.code}${product.name}${product.category.name} - - - - - - - Mã sản phẩmTên sản phẩmPhân loạiThao tác
-
-
-
-

- Hiển thị ${requestScope.currentPage * requestScope.limit < requestScope.numOfPro ? requestScope.currentPage * requestScope.limit : requestScope.numOfPro} - trên ${requestScope.numOfPro} sản phẩm -

+ + + + + ${product.code} + ${product.name} + ${product.category.name} + + + + + + + + + + + +
-
- +
- + + +
+
+

Không có sản phẩm nào để quản lí.

+
+
+