<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國際加速解決方案。 廣告
                ### 71.8 自定義ViewResolvers `ViewResolver`是Spring MVC的核心組件,它負責轉換`@Controller`中的視圖名稱到實際的`View`實現。注意`ViewResolvers`主要用在UI應用中,而不是REST風格的服務(`View`不是用來渲染`@ResponseBody`的)。Spring有很多你可以選擇的`ViewResolver`實現,并且Spring自己對如何選擇相應實現也沒發表意見。另一方面,Spring Boot會根據classpath上的依賴和應用上下文為你安裝一或兩個`ViewResolver`實現。`DispatcherServlet`使用所有在應用上下文中找到的解析器(resolvers),并依次嘗試每一個直到它獲取到結果,所以如果你正在添加自己的解析器,那就要小心順序和你的解析器添加的位置。 `WebMvcAutoConfiguration`將會為你的上下文添加以下`ViewResolvers`: - bean id為`defaultViewResolver`的`InternalResourceViewResolver`,它會定位可以使用`DefaultServlet`渲染的物理資源(比如靜態資源和JSP頁面)。它在視圖名上應用了一個前綴和后綴(默認都為空,但你可以通過`spring.view.prefix`和`spring.view.suffix`設置),然后查找在servlet上下文中具有該路徑的物理資源,可以通過提供相同類型的bean覆蓋它。 - id為`beanNameViewResolver`的`BeanNameViewResolver`,它是視圖解析器鏈的一個非常有用的成員,可以在`View`解析時收集任何具有相同名稱的beans,沒必要覆蓋或替換它。 - id為`viewResolver`的`ContentNegotiatingViewResolver`,它只會在實際`View`類型的beans出現時添加。這是一個'master'解析器,它的職責會代理給其他解析器,它會嘗試找到客戶端發送的一個匹配'Accept'的HTTP頭部。這有一篇關于[ContentNegotiatingViewResolver](https://spring.io/blog/2013/06/03/content-negotiation-using-views)的博客,你也可以也查看下源碼。通過定義一個名叫'viewResolver'的bean,你可以關閉自動配置的`ContentNegotiatingViewResolver`。 - 如果使用Thymeleaf,你將有一個id為`thymeleafViewResolver`的`ThymeleafViewResolver`,它會通過加前綴和后綴的視圖名來查找資源(外部配置為`spring.thymeleaf.prefix`和`spring.thymeleaf.suffix`,對應的默認為'classpath:/templates/'和'.html')。你可以通過提供相同名稱的bean來覆蓋它。 - 如果使用FreeMarker,你將有一個id為`freeMarkerViewResolver`的`FreeMarkerViewResolver`,它會使用加前綴和后綴(外部配置為`spring.freemarker.prefix`和`spring.freemarker.suffix`,對應的默認值為空和'.ftl')的視圖名從加載路徑(外部配置為`spring.freemarker.templateLoaderPath`,默認為'classpath:/templates/')下查找資源。你可以通過提供相同名稱的bean來覆蓋它。 - 如果使用Groovy模板(實際上只要你把groovy-templates添加到classpath下),你將有一個id為`groovyTemplateViewResolver`的`Groovy TemplateViewResolver`,它會使用加前綴和后綴(外部屬性為`spring.groovy.template.prefix`和`spring.groovy.template.suffix`,對應的默認值為'classpath:/templates/'和'.tpl')的視圖名從加載路徑下查找資源。你可以通過提供相同名稱的bean來覆蓋它。 - 如果使用Velocity,你將有一個id為`velocityViewResolver`的`VelocityViewResolver`,它會使用加前綴和后綴(外部屬性為`spring.velocity.prefix`和`spring.velocity.suffix`,對應的默認值為空和'.vm')的視圖名從加載路徑(外部屬性為`spring.velocity.resourceLoaderPath`,默認為'classpath:/templates/')下查找資源。你可以通過提供相同名稱的bean來覆蓋它。 更多詳情可查看源碼: ?[WebMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v1.4.1.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java),[ThymeleafAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v1.4.1.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java),[FreeMarkerAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v1.4.1.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java),[GroovyTemplateAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v1.4.1.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java),[VelocityAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v1.4.1.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java)。
                  <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>

                              哎呀哎呀视频在线观看