zhijiezhao 3 years ago
parent
commit
bf9d585221

+ 4 - 1
src/main/java/com/caimei/www/config/CustomExceptionHandler.java

@@ -1,5 +1,6 @@
 package com.caimei.www.config;
 
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
@@ -11,13 +12,14 @@ import reactor.core.publisher.Mono;
  * @author : Charles
  * @date : 2020/8/7
  */
+@Slf4j
 @ControllerAdvice
 public class CustomExceptionHandler {
 
     @ExceptionHandler(Exception.class)
     public String convertExceptionMsg(Exception e) {
         //自定义逻辑,可返回其他值
-        e.printStackTrace();
+        log.error("异常处理:", e);
         return "error/404";
     }
 
@@ -25,6 +27,7 @@ public class CustomExceptionHandler {
     @ResponseBody
     public Mono<String> convertIllegalAccessError(Exception e) {
         //自定义逻辑,可返回其他值
+        log.error("异常处理:", e);
         return Mono.just("illegal access");
     }
 }

+ 6 - 2
src/main/java/com/caimei/www/controller/unlimited/ProductController.java

@@ -207,8 +207,12 @@ public class ProductController extends BaseController {
             productParams.append("&brandIds=").append(bpn);
         }
         JSONObject productObj = productService.getProductListJson(productParams.toString());
-        Integer totalCount = productObj.getInteger("total");
-        JSONArray productList = (JSONArray) productObj.get("items");
+        Integer totalCount = 0;
+        JSONArray productList = new JSONArray();
+        if (null != productObj) {
+            totalCount = productObj.getInteger("total");
+            productList = (JSONArray) productObj.get("items");
+        }
         model.addAttribute("productCount", totalCount);
         model.addAttribute("productListJson", productList);
 

+ 7 - 5
src/main/resources/templates/product/instruelist.html

@@ -244,11 +244,13 @@
     <!--分页-->
     <div v-if="(!isPC) && noMore" class="noMore">---- 没有更多了 ----</div>
     <div v-if="isPC && pageTotal>1" class="pageWrap clear">
-        <th:block th:each="page : ${pageBtnList}">
-            <a th:if="${page.btn} == -1" class="prev" th:href="${page.path}"></a>
-            <span th:if="${page.btn} == 0">···</span>
-            <a th:if="${page.btn} > 0" th:class="${page.btn == pageBtnNum} ? 'on' : ''" th:href="${page.path}" th:text="${page.btn}"></a>
-            <a th:if="${page.btn} == -2" class="next" th:href="${page.path}"></a>
+        <th:block th:if="not${#lists.isEmpty(pageBtnList)}">
+            <th:block th:each="page : ${pageBtnList}">
+                <a th:if="${page.btn} == -1" class="prev" th:href="${page.path}"></a>
+                <span th:if="${page.btn} == 0">···</span>
+                <a th:if="${page.btn} > 0" th:class="${page.btn == pageBtnNum} ? 'on' : ''" th:href="${page.path}" th:text="${page.btn}"></a>
+                <a th:if="${page.btn} == -2" class="next" th:href="${page.path}"></a>
+            </th:block>
         </th:block>
         <span>共<b v-text="pageTotal>1?pageTotal:1"></b>页</span>
         <span>跳至</span>