<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                SpringBoot 默認到`resources/templates/error/`目錄下掃描錯誤的頁面,并根據模板名稱來映射對應的錯誤。如下: ``` 假設你創建了 resources/templates/error/4xx.html模板和resources/templates/error/404.html 如果發生精確的錯誤,如404,則采用404.html渲染錯誤數據,否則采用4xx.html ``` <br/> 所以定制錯誤頁面的步驟如下: **1. 錯誤數據由DefaultErrorAttributes提供** ```java -----DefaultErrorAttributes----- errorAttributes.put("status", 999); // 狀態碼 errorAttributes.put("error", "None"); // 錯誤提示 errorAttributes.put("exception", error.getClass().getName()); // 異常對象 errorAttributes.put("message", message); // 消息 errorAttributes.put("errors", result.getAllErrors()); // jsr303數據校驗錯誤提示 errorAttributes.put("trace", stackTrace.toString()); errorAttributes.put("path", path); errorAttributes.put("timestamp", new Date()); ``` **2. 定制錯誤頁面** (1)*`resources/templates/error/404.html`* ```html <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>404</title> </head> <body> <div>Status:[[${status}]]</div> <div>Error:[[${error}]]</div> <div>Exception:[[${exception}]]</div> <div>Message:[[${message}]]</div> <div>Errors:[[${errors}]]</div> <div>Trace:[[${trace}]]</div> <div>Path:[[${path}]]</div> <div>Timestamp:[[${timestamp}]]</div> </body> </html> ``` (2)*`resources/templates/error/4xx.html`* ```html <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>4xx</title> </head> <body> <div>Status:[[${status}]]</div> <div>Error:[[${error}]]</div> <div>Exception:[[${exception}]]</div> <div>Message:[[${message}]]</div> <div>Errors:[[${errors}]]</div> <div>Trace:[[${trace}]]</div> <div>Path:[[${path}]]</div> <div>Timestamp:[[${timestamp}]]</div> </body> </html> ``` **3. 測試** 啟動項目后訪問一個不存在的地址 http://localhost:8080/abc 時,得到如下結果。 ![](https://img.kancloud.cn/31/51/3151667159d1df858ea573f0a57bf4a7_1561x319.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看