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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Spring MVC `ResourceBundleViewResolver`配置示例 > [https://howtodoinjava.com/spring-mvc/spring-mvc-resourcebundleviewresolver-configuration-example/](https://howtodoinjava.com/spring-mvc/spring-mvc-resourcebundleviewresolver-configuration-example/) 在先前的示例中,我們了解了[`XmlViewResolver`](https://howtodoinjava.com/best-practices/spring-mvc-xmlviewresolver-configuration-example/)和[`InternalResourceViewResolver`](https://howtodoinjava.com/spring/spring-mvc/spring-mvc-internalresourceviewresolver-configuration-example/)視圖模板。 在這篇文章中,我們將學習[`ResourceBundleViewResolver`](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/view/ResourceBundleViewResolver.html)模板。 `ResourceBundleViewResolver`從類路徑根目錄中的資源包中加載視圖 bean。 請注意,`ResourceBundleViewResolver`還可以利用資源包功能從不同的資源包中為不同的區域加載視圖 Bean(這對于其他兩個視圖解析器是不可能的)。 默認情況下,`ResourceBundleViewResolver`從存在的“ `views.properties`”文件中將視圖名稱加載到類路徑中,但是可以通過**基本名稱**屬性覆蓋此位置。 ```java <bean class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> <property name="basename" value="views" /> </bean> ``` 在`views.properties`資源包中,您可以以屬性的格式聲明視圖 bean,并且它們的聲明等效于[`XmlViewResolver`示例](https://howtodoinjava.com/best-practices/spring-mvc-xmlviewresolver-configuration-example/)中看到的 XML bean 聲明。 ```java <!--beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="home" class="org.springframework.web.servlet.view.JstlView"> <property name="url" value="/WEB-INF/jsp/home.jsp" /> </bean> <bean id="admin/home" class="org.springframework.web.servlet.view.JstlView"> <property name="url" value="/WEB-INF/jsp/admin/home.jsp" /> </bean> <bean id="logOffRedirect" class="org.springframework.web.servlet.view.RedirectView"> <property name="url" value="home" /> </bean> </beans--> //Equivalent resource bundle properites home.(class)=org.springframework.web.servlet.view.JstlView home.url=/WEB-INF/jsp/home.jsp adminHome.(class)=org.springframework.web.servlet.view.JstlView adminHome.url=/WEB-INF/jsp/admin/home.jsp logOffRedirect.(class)=org.springframework.web.servlet.view.RedirectView logOffRedirect.url=home ``` > 通過上述配置,當控制器返回邏輯視圖名稱`home`時,`ResourceBundleViewResolver`將在`views.properties`文件中找到以`home`開頭的密鑰,并將相應視圖的 URL 返回到[`DispatcherServlet`](https://howtodoinjava.com/spring/spring-mvc/spring-mvc-hello-world-example/),即`/WEB-INF/jsp/home.jsp`。 如果有什么需要更多的解釋的話,請問我。 **祝您學習愉快!**
                  <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>

                              哎呀哎呀视频在线观看