title: Spring MVC with multiple view resolvers
body: <p>I tried to use 2 view resolvers:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
  
      &lt;context:component-scan base-package="com.evgeni.dfr.controller" /&gt;
  
      &lt;context:annotation-config /&gt;
      &lt;mvc:annotation-driven /&gt;
  
      &lt;bean id="viewResolver"
          class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
          &lt;property name="cache" value="false" /&gt;
          &lt;property name="viewClass" value="com.evgeni.drf.faces.FacesView" /&gt;
          &lt;property name="prefix" value="/WEB-INF/pages/" /&gt;
          &lt;property name="suffix" value=".xhtml" /&gt;
  
          &lt;property name="order" value="1" /&gt;
      &lt;/bean&gt;
  
      &lt;bean
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix"&gt;
              &lt;value&gt;/WEB-INF/views/&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="suffix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="order" value="0" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>The application always uses only the one with the lowest order and not the other. In the current case if my controller return "someView" the app will respond with <code>The requested resource (/MyProject/WEB-INF/views/someView.jsp) is not available.</code> even if there is "pages/someView.xhtml". </p>
  
  <p>Spring version - 3.2.3</p>
  
  <p>Edit:
  If I have 2 methods in controller and methodA returns "viewA" and methodB returns "viewB". And we have viewA.jsp in 'views' folder and viewB.xhtml in 'pages'.</p>
  
  <p>Case1: UrlBasedViewResolver -> order=1,InternalResourceViewResolver -> order=2</p>
  
  <p>methodA -> <code>The requested resource (/MyProject/WEB-INF/pages/viewA.xhtml) is not available.</code>; </p>
  
  <pre><code>methodB -&gt; OK
  </code></pre>
  
  <p>Case2: UrlBasedViewResolver -> order=2,InternalResourceViewResolver -> order=1</p>
  
  <p>methodA -> OK ;</p>
  
  <pre><code>methodB -&gt; `The requested resource (/MyProject/WEB-INF/views/viewB.jsp) is not available.`;
  </code></pre>