title: Spring with Thymeleaf view integration
body: <p>Starting out with Spring MVC and Thymeleaf for a project - But I am facing the issue of loading the index page - </p>
  
  <p>My Controller is as follows - </p>
  
  <pre><code>@Controller
  
  public class HomeController {
  
          @RequestMapping(method=RequestMethod.GET, value="/")
          public ModelAndView index(){
              ModelAndView mav = new ModelAndView();
              mav.setViewName("index");
              mav.addObject("user", new UserCredential());
              return mav;
          }
  </code></pre>
  
  <p>and my servlet.xml file is </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"&gt;
  
      &lt;context:component-scan base-package="web.controller" /&gt;
  
      &lt;!-- Enabling Spring MVC configuration through annotations --&gt;
      &lt;mvc:annotation-driven /&gt;
  
      &lt;!--  Mapping Static Resources --&gt;
      &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt;
  
      &lt;bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/views/" /&gt;
          &lt;property name="suffix" value=".html" /&gt;
          &lt;property name="templateMode" value="HTML5" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine"&gt;
          &lt;property name="templateResolver" ref="templateResolver" /&gt;
      &lt;/bean&gt;
  
      &lt;bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver"&gt;
          &lt;property name="templateEngine" ref="templateEngine" /&gt;
          &lt;property name="order" value="1" /&gt;
          &lt;property name="viewNames" value="*.html"/&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>My file structure is -- </p>
  
  <pre><code>WebContent
   -- WEB_INF
      -- views
        -- index.html
  </code></pre>
  
  <p>However I get the following exception - </p>
  
  <p><code>javax.servlet.ServletException: Could not resolve view with name 'index1' in servlet with name</code> 'springMVC'</p>
  
  <p>Am I placing the file in the wrong place or missing something in my controller?</p>