title: Could not resolve view with name 'htmlviews/index.html' in servlet with name 'dispatcher' using javaconfig
body: <p>I get such exception:</p>
  
  <pre><code>javax.servlet.ServletException: Could not resolve view with name 'htmlviews/index.html' in servlet with name 'dispatcher'
  org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1211)
  org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>when I try to connect to fully java configured spring web service. </p>
  
  <p>My configuration classes:</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  @ComponentScan({"config", "controller"})
  public class MyWebConfig extends WebMvcConfigurerAdapter {
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/htmlviews/**").addResourceLocations("/htmlviews/");
      }
  }
  </code></pre>
  
  <p>Initializer:</p>
  
  <pre><code>    public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
  
      protected Class&lt;?&gt;[] getRootConfigClasses() {
          return new Class&lt;?&gt;[]{MyWebConfig.class};
      }
  
      protected Class&lt;?&gt;[] getServletConfigClasses() {
          return null;
      }
  
      protected String[] getServletMappings() {
          return new String[]{"/"};
      }
  }
  </code></pre>
  
  <p>and controller:</p>
  
  <pre><code>@Controller
  public class IndexController {
  
      @RequestMapping(value = "/")
      public String getIndexPage() {
          return "htmlviews/index.html";
      }
  
      @RequestMapping(value = "/{[path:[^\\.]*}")
      public String index() {
          return "forward:/";
      }
  }
  </code></pre>
  
  <p>whole file srtucture is simple :</p>
  
  <p><a href="https://i.stack.imgur.com/MGCrX.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/MGCrX.jpg" alt="whole file srtucture is simple :"></a></p>
  
  <p>I am using Idea IDE (also tried in eclipse, same exception) and trying to deploy on tomcat. In <code>pom.xml</code>, I added 'jstl' dependency, but that did not help to resolve problem.
   Using <code>xml</code> configuration everything works well. I have no idea what is wrong with my spring java configuration, it is super simple, maybe I forgot something?</p>
  
  <p><strong>Fixed it</strong> 
  Everything started working when I changed spring version from <code>4.1.0.RELEASE</code> to <code>4.2.3.RELEASE</code> . I do not why it does not work with <code>4.1.0.RELEASE</code>. Maybe someone can explain, just curious.</p>