title: Spring 3.1 Type Level RequestMapping and logical view names
body: <p>a question about type-level wildcard request mapping and Springs logical view names derived from void and domain object returns. Say I have the following</p>
  
  <pre><code>@Controller
  class HomeController
  {
      @RequestMapping(value="/")
      public void index () {}
  }
  </code></pre>
  
  <p>My understanding of how Springs logical view name generation is that the above controller will map "/" to the logical view name "index" which I can then, for example, use Apache Tiles to match against an appropriate jsp view. </p>
  
  <p>Similarly, this demonstrates my understanding of Springs logical view name creation (but I think I'm missing something...)</p>
  
  <pre><code>@Controller
  @RequestMapping("/collection/*")
  class CollectionController
  {
  
      @Autowired
      private SomeService someService;
  
      @RequestMapping(method=RequestMethod.GET)
      public List&lt;Item&gt; list ()
      {
          // in my understanding
          // itemList should be available in the model (via generated name),
          // that the logical view name generated should be
          // collection/list and that this method
          // would intercept the url "/collection/" or "/collection"
          return someService.getItems();
      }
  
      @RequestMapping("/{itemId}")
      public Item item (@PathVariable final String itemId)
      {
          // similiarly, item should be available in the
          // model and the logical view name should be
          // collection/item
          return someService.getItem(itemId);
      }
  }
  </code></pre>
  
  <p>Thing is, is that the list method is never resolved as the 'index' page of the collection- instead, the logical view name appears to be "collection" (which I havent defined- I want the logical view name to be "collection/list". The 'item' method works- its just that the index page does not- sorry for the vague question- not sure how else to put it-</p>
  
  <p>How can I take advantage of Springs logical view name generation from method names based on wildcard urls on the type level without returning strings to define the logical view name? The above does not work the way I expected. What am I missing? </p>
  
  <p>UPDATE:</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  public class WebConfig extends WebMvcConfigurerAdapter
  {
  
      static private String [] TILES_DEFINITIONS= new String [] { "/WEB-INF/layouts/tiles.xml", "/WEB-INF/views/**/tiles.xml"};
  
      /* static resource resolution */ 
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) 
      {
          registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
      }
  
      /**
       * ViewResolver configuration required to work with Tiles2-based views.
       */
      @Bean  
      public ViewResolver viewResolver ()
      {
          UrlBasedViewResolver viewResolver= new UrlBasedViewResolver();
          viewResolver.setViewClass(TilesView.class);
          return viewResolver;
      }
  
      /**
       * Configures Tiles at application startup.
       */
      @Bean
      public TilesConfigurer tilesConfigurer () 
      {
          final TilesConfigurer configurer= new TilesConfigurer();
          configurer.setDefinitions(TILES_DEFINITIONS);
          configurer.setCheckRefresh(true);
          return configurer;
      }
  }
  </code></pre>
  
  <p>And my tiles folder structure is</p>
  
  <pre><code>src/main/webapp/layouts (contains base page.jsp)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>src/main/webapp/views/[VIEWNAME]/tiles.xml
  </code></pre>
  
  <p>where VIEWNAME is a view name (sorry!) and view paths for that view name are defined in that folders tiles.xml. Hope that makes things clearer...</p>