title: Tomcat8, Spring4, Thymeleaf2 Java configuration showing blank page
body: <p>I'm so close to having this working but I'm missing something simple. </p>
  
  <p>When my RestController returns a string "index" it should go to index.html but instead I get a blank page that say "index" on it. It's got to be my config is off but I don't know how.</p>
  
  <p>I put my index.html into WEB-INF\templates and it just contains a paragraph that says "Hello World". I thought about using Spring Boot but I want to figure this out so I'm skipping that for now. Plus I think I'm pretty close to getting this working.</p>
  
  <p>What stands for my applicationContext.xml:</p>
  
  <pre><code>@Configuration
  @ComponentScan({"com.spring.poc.web"})
  @EnableWebMvc
  public class SpringWebConfig extends WebMvcConfigurerAdapter {
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/resources/**")
                  .addResourceLocations("/resources/");
      }
  
      @Bean
        public ViewResolver viewResolver() {
          ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
          templateResolver.setCacheable(false);
          templateResolver.setPrefix("/WEB-INF/templates/");
          templateResolver.setSuffix(".html");
          templateResolver.setTemplateMode("HTML5");
  
          SpringTemplateEngine templateEngine = new SpringTemplateEngine();
          templateEngine.setTemplateResolver(templateResolver);
  
          ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
          viewResolver.setCharacterEncoding("UTF-8");
          viewResolver.setOrder(1);
          viewResolver.setTemplateEngine(templateEngine);
  
          return viewResolver;
        }
  }
  </code></pre>
  
  <p>Where my spring @Services are:</p>
  
  <pre><code>@Configuration
  @ComponentScan({"com.nox.poc.service"})
  public class SpringRootConfig {
  
  }
  </code></pre>
  
  <p>What represents my web.xml</p>
  
  <pre><code>    public class WebXmlInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
  
      @Override
      protected Class&lt;?&gt;[] getRootConfigClasses() {
          return new Class[] { SpringRootConfig.class };
      }
  
      @Override
      protected Class&lt;?&gt;[] getServletConfigClasses() {
          return new Class[] { SpringWebConfig.class };
      }
  
      @Override
      protected String[] getServletMappings() {
          return new String[] { "/"};
      }
  
  }
  </code></pre>
  
  <p>My Controller:</p>
  
  <pre><code>@RestController
  public class PocRestController {
  
  
  
      @RequestMapping(value = "/")
      public String getMainPage(ModelMap map) {
  
          return "index";
      }   
  
  }
  </code></pre>
  
  <p>My pom.xml (I'm using Eclipse Mars):</p>
  
  <pre><code>    project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.spring.poc&lt;/groupId&gt;
    &lt;artifactId&gt;pocApp&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;properties&gt;
          &lt;spring.version&gt;4.2.2.RELEASE&lt;/spring.version&gt;
          &lt;jackson.version&gt;2.6.3&lt;/jackson.version&gt;
          &lt;faces.version&gt;2.2.12&lt;/faces.version&gt;
      &lt;/properties&gt;
  
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- jackson allows spring RestController to bind whatever we send back as JSON --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
              &lt;version&gt;${jackson.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
              &lt;version&gt;${jackson.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.inject&lt;/groupId&gt;
              &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
              &lt;version&gt;1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
              &lt;version&gt;1.1.3&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
              &lt;version&gt;3.1.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.thymeleaf&lt;/groupId&gt;
              &lt;artifactId&gt;thymeleaf-spring4&lt;/artifactId&gt;
              &lt;version&gt;2.1.4.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.3&lt;/version&gt;
          &lt;configuration&gt;
            &lt;source&gt;1.8&lt;/source&gt;
            &lt;target&gt;1.8&lt;/target&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.6&lt;/version&gt;
          &lt;configuration&gt;
            &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
            &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>When I start tomcat 8 in Eclipse everything starts fine, nothing in the external log files. However when I hit localhost:8080\pocApp\</p>
  
  <p>I get a blank page that says "index". So clearly I'm missing some configuration but I haven't found the answer. It has to be something small...</p>