<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                全局異常可以捕捉整個 Web 項目的異常并進行處理,需要在`springmvc-servlet.xml`文件中進行 SimpleMappingExceptionResolver 的配置,它會在發生異常時使用對應的視圖來報告異常。 <br/> 配置步驟如下: **1. 在`resources/springmvc-servlet.xml`配置SimpleMappingExceptionResolver** ```xml <!-- 全局異常配置 --> <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <!-- 只要異常類型是ArrayIndexOutOfBoundsException或者它的子類就會被處理,如果需要處理多種類型的異常,請配置多個<prop /> key: 異常類型,可以是自定義的異常類 outerror: 視圖名,當key指定的異常發生時,由該視圖進行顯示 --> <prop key="java.lang.ArrayIndexOutOfBoundsException">outerror</prop> </props> </property> </bean> ``` **2. 在controller層發生數組下標越界異常** ```java @RequestMapping("/v6/get/student") public String getStudent06() { int[] ints = new int[1]; ints[0] = 100; ints[1] = 200; return "student"; } ``` **3. 視圖層顯示異常信息** `webapp/WEB-INF/views/outerror.jsp` ```html <h1>---${ ex }---</h1> ``` **4. 測試** 啟動項目訪問 http://localhost:8080/mvc/v6/get/student ,前端將會看到如下信息。 ``` ---java.lang.ArrayIndexOutOfBoundsException: 1--- ``` <br/> 局部異常和全局異常共同使用,則局部異常優先,所以想要全局異常生效,最好不要使用局部異常。
                  <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>

                              哎呀哎呀视频在线观看