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