title: How to properly configure TilesViewResolver in Spring MVC?
body: <p>I have Spring MVC project and I would like to build views in my application using Apache Tiles. I have added some dependencies to my <code>pom.xml</code> file. I am wondering I have too many but I have had some exceptions about missing classes so I found them in some packages and have added them to classpath.</p>
  
  <pre><code>&lt;!-- Tiles --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-extras&lt;/artifactId&gt;
          &lt;version&gt;2.2.2&lt;/version&gt;
      &lt;/dependency&gt;         
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-jsp&lt;/artifactId&gt;
          &lt;version&gt;2.2.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-core&lt;/artifactId&gt;
          &lt;version&gt;2.2.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-servlet&lt;/artifactId&gt;
          &lt;version&gt;2.1.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
        &lt;artifactId&gt;commons-digester3&lt;/artifactId&gt;
        &lt;version&gt;3.2&lt;/version&gt;
        &lt;classifier&gt;with-deps&lt;/classifier&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
          &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
          &lt;version&gt;1.8.3&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>This is my <code>ViewResolvers</code> configuration in Dispatcher Servlet Context. I am wondering how to properly configure them together.</p>
  
  <pre><code>&lt;beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;
      &lt;beans:property name="definitions"&gt;
          &lt;beans:list&gt;
              &lt;beans:value&gt;/WEB-INF/tiles-definitions.xml&lt;/beans:value&gt;
          &lt;/beans:list&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt; 
  
  &lt;beans:bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
      &lt;beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" /&gt;
      &lt;beans:property name="order" value="0" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;beans:property name="prefix" value="/WEB-INF/views/" /&gt;
      &lt;beans:property name="suffix" value=".jsp" /&gt;
      &lt;beans:property name="order" value="1" /&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>I have read this question and answer: <a href="https://stackoverflow.com/q/1029193/845220">How to use multiple ViewResolvers in Spring?</a> but it haven't been helpful for me. At this moment with above configurations <code>jsp</code> views works properly but for tiles addresses I am getting <code>HTTP Status 404</code>.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is my controller. The view connected with "home" is working but others - tiles aren't working.</p>
  
  <pre><code> @RequestMapping(value = "/", method = RequestMethod.GET)
  public String home(Locale locale, Model model) {        
      return "home";
  }
  
  @RequestMapping(value = "/pets", method = RequestMethod.GET)
  public String pets(Locale locale, Model model) {
      return "pets-tiles";
  }   
  
  @RequestMapping(value = "/dogs", method = RequestMethod.GET)
  public String dogs(Locale locale, Model model) {
      return "dogs-tiles";
  }   
  
  @RequestMapping(value = "/cats", method = RequestMethod.GET)
  public String cats(Locale locale, Model model) {
      return "cats-tiles";
  }   
  </code></pre>
  
  <p>And this is my <code>tiles-definitions.xml</code> file:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;!DOCTYPE tiles-definitions PUBLIC
     "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
     "http://tiles.apache.org/dtds/tiles-config_2_0.dtd"&gt;
   &lt;tiles-definitions&gt;
  
    &lt;definition name="template-main" template="/WEB-INF/views/layouts/main.jsp"&gt;
     &lt;put-attribute name="banner-content" value="/WEB-INF/views/sections/banner.jsp" /&gt;
     &lt;put-attribute name="title-content" value="Pet Type" /&gt;
     &lt;put-attribute name="primary-content" value="" /&gt;
     &lt;put-attribute name="footer-content" value="/WEB-INF/views/sections/footer.jsp" /&gt;
    &lt;/definition&gt;
  
    &lt;definition name="template-detail" template="/WEB-INF/views/layouts/detail.jsp"&gt;
     &lt;put-attribute name="banner-content" value="/WEB-INF/views/sections/banner.jsp" /&gt;
     &lt;put-attribute name="title-content" value="Pet Type" /&gt;
     &lt;put-attribute name="subtitle-content" value="" /&gt;
     &lt;put-attribute name="primary-content" value="" /&gt;
     &lt;put-attribute name="footer-content" value="/WEB-INF/views/sections/footer.jsp" /&gt;
    &lt;/definition&gt;
  
    &lt;definition name="pet-tiles" extends="template-main"&gt;
     &lt;put-attribute name="primary-content" value="/WEB-INF/views/contents/pets.jsp" /&gt;
    &lt;/definition&gt;
  
    &lt;definition name="dog-tiles" extends="template-detail"&gt;
     &lt;put-attribute name="subtitle-content" value="Canines" /&gt;
     &lt;put-attribute name="primary-content" value="/WEB-INF/views/contents/dogs.jsp" /&gt;
    &lt;/definition&gt;
  
    &lt;definition name="cat-tiles" extends="template-detail"&gt;
     &lt;put-attribute name="subtitle-content" value="Felines" /&gt;
     &lt;put-attribute name="primary-content" value="/WEB-INF/views/contents/cats.jsp" /&gt;
    &lt;/definition&gt;
  
   &lt;/tiles-definitions&gt;
  </code></pre>
  
  <p>They come from this tutorial: <a href="http://krams915.blogspot.com/2010/12/spring-mvc-3-tiles-2-integration.html" rel="nofollow noreferrer">http://krams915.blogspot.com/2010/12/spring-mvc-3-tiles-2-integration.html</a> But not working for me.</p>