Tôi cố gắng để sử dụng 2 điểm phân giải:Spring MVC với nhiều quan điểm phân giải
<?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"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<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
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
<property name="order" value="0" />
</bean>
</beans>
Ứng dụng này luôn luôn chỉ sử dụng một trong những trình tự thấp nhất và không phải là khác. Trong trường hợp hiện tại nếu bộ điều khiển của tôi trả về "someView", ứng dụng sẽ phản hồi với The requested resource (/MyProject/WEB-INF/views/someView.jsp) is not available.
ngay cả khi có "trang/someView.xhtml".
phiên bản mùa xuân - 3.2.3
Edit: Nếu tôi có 2 phương pháp trong điều khiển và methodA trả "viewA" và methodB trả "viewB". Và chúng tôi có viewA.jsp trong thư mục 'views' và viewB.xhtml trong 'pages'.
Trường hợp1: UrlBasedViewResolver -> trật tự = 1, InternalResourceViewResolver -> trật tự = 2
methodA ->The requested resource (/MyProject/WEB-INF/pages/viewA.xhtml) is not available.
;
methodB -> OK
Trường hợp2: UrlBasedViewResolver -> trật tự = 2, InternalResourceViewResolver -> trật tự = 1
methodA -> OK;
methodB -> `The requested resource (/MyProject/WEB-INF/views/viewB.jsp) is not available.`;
Tôi đã cập nhật câu hỏi của mình, hy vọng nó rõ ràng hơn bây giờ. –
Kiểm tra chỉnh sửa của tôi. Trường hợp sử dụng của bạn là gì. Tại sao bạn sử dụng hai UrlBasedViewResolver đó. –