我认为你误解了订单优先级。该
ViewResolver最高顺序是链中最后一个解析器。由于你给的
InternalResourceViewResolver订单是
0,因此它将成为链中的第一个解析器,并且
InternalResourceViewResolver无论返回什么视图名称,都会解析该视图。因此,如果要使用多个解析器,则
InternalResourceViewResolver必须是顺序最高的解析器。
将
InternalResourceViewResolver订单值更改为2:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans 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"> <context:component-scan base-package="com.evgeni.dfr.controller" /> <context:annotation-config /> <mvc:annotation-driven /> <bean id="viewResolver" > <property name="cache" value="false" /> <property name="viewClass" value="com.evgeni.drf.faces.FacesView" /> <property name="prefix" value="/WEB-INF/pages/" /> <property name="suffix" value=".xhtml" /> <property name="order" value="1" /> </bean> <bean > <property name="prefix"> <value>/WEB-INF/views/</value> </property> <property name="suffix"> <value>.jsp</value> </property> <property name="order" value="2" /> </bean></beans>
编辑:
检查javadoc后,似乎这两个解析程序无法链接,因为
InternalResourceViewResolver是
UrlbasedViewResolver(InternalResourceViewResolver扩展了
UrlbasedViewResolver)。两个解析器始终与返回值匹配。我认为你将需要一些自定义功能才能执行此操作。



