<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國際加速解決方案。 廣告
                # 第四章 Controller接口控制器詳解 (4)——跟著開濤學SpringMVC 4.12、ParameterizableViewController 參數化視圖控制器,不進行功能處理(即靜態視圖),根據參數的邏輯視圖名直接選擇需要展示的視圖。 1. &lt;bean?name="/parameterizableView"?? 2. class="org.springframework.web.servlet.mvc.ParameterizableViewController"&gt;?? 3. &lt;property?name="viewName"?value="success"/&gt;?? 4. &lt;/bean&gt;?? 該控制器接收到請求后直接選擇參數化的視圖,這樣的好處是在配置文件中配置,從而避免程序的硬編碼,比如像幫助頁面等不需要進行功能處理,因此直接使用該控制器映射到視圖。 ## 4.13、AbstractUrlViewController 提供根據請求URL路徑直接轉化為邏輯視圖名的支持基類,即不需要功能處理,直接根據URL計算出邏輯視圖名,并選擇具體視圖進行展示: **urlDecode:**是否進行url解碼,不指定則默認使用服務器編碼進行解碼(如Tomcat默認ISO-8859-1); **urlPathHelper:**用于解析請求路徑的工具類,默認為org.springframework.web.util.UrlPathHelper。 UrlFilenameViewController是它的一個實現者,因此我們應該使用UrlFilenameViewController。 ## 4.14、UrlFilenameViewController 將請求的URL路徑轉換為邏輯視圖名并返回的轉換控制器,即不需要功能處理,直接根據URL計算出邏輯視圖名,并選擇具體視圖進行展示: 根據請求URL路徑計算邏輯視圖名; 1. &lt;bean?name="/index1/*"??? 2. class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/&gt;?? 3. &lt;bean?name="/index2/**"??? 4. class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/&gt;?? 5. &lt;bean?name="/*.html"??? 6. class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/&gt;?? 7. &lt;bean?name="/index3/*.html"??? 8. class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/&gt;?? **/index1/*:**可以匹配/index1/demo,但不匹配/index1/demo/demo,如/index1/demo邏輯視圖名為demo; **/index2/**:**可以匹配/index2路徑下的所有子路徑,如匹配/index2/demo,或/index2/demo/demo,“/index2/demo”的邏輯視圖名為demo,而“/index2/demo/demo”邏輯視圖名為demo/demo; **/*.html:**可以匹配如/abc.html,邏輯視圖名為abc,后綴會被刪除(不僅僅可以是html); **/index3/*.html:**可以匹配/index3/abc.html,邏輯視圖名也是abc; 上述模式為Spring Web MVC使用的Ant-style?模式進行匹配的: 1. ?????匹配一個字符,如/index??可以匹配?/index1?,?但不能匹配?/index?或?/index12?? 2. *????匹配零個或多個字符,如/index1/*,可以匹配/index1/demo,但不匹配/index1/demo/demo? 3. **???匹配零個或多個路徑,如/index2/**:可以匹配/index2路徑下的所有子路徑,如匹配/index2/demo,或/index2/demo/demo? 5. 如果我有如下模式,那Spring該選擇哪一個執行呢?當我的請求為“/long/long”時如下所示:? 6. /long/long? 7. /long/**/abc?? 8. /long/**? 9. /**? 10. Spring的AbstractUrlHandlerMapping使用:最長匹配優先;? 11. 如請求為“/long/long”?將匹配第一個“/long/long”,但請求“/long/acd”?則將匹配?“/long/**”,如請求“/long/aa/abc”則匹配“/long/**/abc”,如請求“/abc”則將匹配“/**”?? UrlFilenameViewController還提供了如下屬性: **prefix:**生成邏輯視圖名的前綴; **suffix:**生成邏輯視圖名的后綴; 1. protected?String?postProcessViewName(String?viewName)?{?? 2. return?getPrefix()?+?viewName?+?getSuffix();?? 3. }?? 1. &lt;bean?name="/*.htm"?class="org.springframework.web.servlet.mvc.UrlFilenameViewController"&gt;?? 2. &lt;property?name="prefix"?value="test"/&gt;?? 3. &lt;property?name="suffix"?value="test"/&gt;?? 4. &lt;/bean&gt;?? 當**prefix=“test”,suffix=“test”**,如上所示的**/*.htm:**可以匹配如/abc.htm,但邏輯視圖名將變為testabctest。 [私塾在線學習網](http://sishuok.com/)原創內容([http://sishuok.com](http://sishuok.com/)) 原創內容,轉載請注明私塾在線【[http://sishuok.com/forum/blogPost/list/5498.html](http://sishuok.com/forum/blogPost/list/0/5234.html)】
                  <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>

                              哎呀哎呀视频在线观看