天天看點

java 視圖解析器_[劉陽Java]_InternalResourceViewResolver視圖解析器_第6講

SpringMVC在處理器方法中通常傳回的是邏輯視圖,如何定位到真正的頁面,就需要通過視圖解析器

InternalResourceViewResolver是SpringMVC中比較常用視圖解析器。

1. InternalResourceViewResolver的配置檔案代碼如下

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc.xsd">

如果當處理器傳回“index”時,InternalResourceViewResolver解析器會自動添加字首和字尾,則真實的視圖路徑:/index.jsp

2. SpringMVC中可以配置多個視圖解析器,我們可以通過在配置檔案添加order屬性來設定他們的優先級

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc.xsd">

上面配置檔案中的p:order="10",就是對目前的InternalResourceViewResolver設定優先級。order取值越小優先級越大(即:0為優先級最高,是以優先進行處理視圖)

原文:http://www.cnblogs.com/liuyangjava/p/6761245.html