title: Spring ViewResolver : xml conf ok, the SAME in java fail
body: <p>Hello!</p>
  
  <p>As said in the title I'm trying to export my view resolver config from the classic xml to java conf. (I don't think I'll enter in the reason of this choice..?) </p>
  
  <p>My previous conf is :</p>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/dispatcher-servlet.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  ...
  &lt;servlet&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  </code></pre>
  
  <p>dispatcher-servlet.xml :</p>
  
  <pre><code>&lt;context:component-scan base-package="ca.mat8j8.controller" /&gt;
  
  &lt;!-- freemarker config --&gt;
  &lt;bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"&gt;
      &lt;property name="templateLoaderPath" value="/WEB-INF/views/"/&gt;
  &lt;/bean&gt;
  
  &lt;!--
  View resolvers can also be configured with ResourceBundles or XML files. If you need
  different view resolving based on Locale, you have to use the resource bundle resolver.
  --&gt;
  &lt;bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"&gt;
      &lt;property name="cache" value="true"/&gt;
      &lt;property name="prefix" value=""/&gt;
      &lt;property name="suffix" value=".ftl"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>This way, it work without problem.</p>
  
  <p>Now I try to get rid of my xml conf like that:</p>
  
  <p>web.xml :</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/dispatcher-servlet.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  ...
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;!--Configure DispatcherServlet to use AnnotationConfigWebApplicationContext instead of default XmlWebApplicationContext.--&gt; 
      &lt;init-param&gt;
          &lt;param-name&gt;contextClass&lt;/param-name&gt;
          &lt;param-value&gt;org.springframework.web.context.support.AnnotationConfigWebApplicationContext&lt;/param-value&gt;
      &lt;/init-param&gt;
       &lt;!--Custom web configuration annotated class.  --&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;ca.mat8j8.configuration.WebConfiguration&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  </code></pre>
  
  <p>I empty dispatcher-servlet.xml, and create WebConfiguration :</p>
  
  <pre><code>@Configuration
  @ComponentScan(basePackages = { "ca.mat8j8.controller" })
  public class WebConfiguration extends WebMvcConfigurationSupport {
  
  @Bean
  public ViewResolver viewResolver() {
      final FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
      resolver.setCache(true);
      resolver.setPrefix("");
      resolver.setSuffix(".ftl");
      return resolver;
  }
  
  @Bean
  public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
      FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
      factory.setTemplateLoaderPath("/WEB-INF/views/");
      final FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
      configurer.setConfiguration(factory.createConfiguration());
      return configurer;
  }
  }
  </code></pre>
  
  <p>On startup, I can see that it pass through my java webConf(breakpoints).
  In my head, it should do the same thing, but when I try now to reach my "home" view (which worked with the xml conf), I've got this very interesting :</p>
  
  <pre><code>GRAVE: Servlet.service() for servlet [dispatcher] in context with path [] threw exception [Could not resolve view with name 'home' in servlet with name 'dispatcher'] with root cause
  javax.servlet.ServletException: Could not resolve view with name 'home' in servlet with name 'dispatcher'
  at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1211)
  at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
  .....
  </code></pre>
  
  <p>For info, I work with tomcat 8, java 8, and spring 4.1.5.</p>
  
  <p>Thank you to have read so far, thanks in advance for your answers ;-)</p>