title: Thymeleaf: Error Resolving Template
body: <p>I am trying to use layouts/templates with Thymeleaf but I'm getting the following exception.</p>
  
  <blockquote>
    <p>Exception processing template "user/index": Error resolving template "/layouts/default.html", template might not exist or might not be accessible by any of the configured Template Resolvers</p>
  </blockquote>
  
  <p>Here is my ThymeleafConfig.java</p>
  
  <pre><code>@Configuration
  public class ThymeleafConfig {
  
      @Bean
      public ServletContextTemplateResolver templateResolver() {
          ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
          resolver.setPrefix("/WEB-INF/views/");
          resolver.setSuffix(".html");
          resolver.setTemplateMode("HTML5");
          resolver.setOrder(1);
          return resolver;
      }
  
      @Bean
      public SpringTemplateEngine templateEngine() {
          SpringTemplateEngine engine = new SpringTemplateEngine();
          engine.setTemplateResolver(templateResolver());
          engine.addDialect(new LayoutDialect());
          engine.addDialect(new SpringSecurityDialect());
          engine.addDialect(new SpringStandardDialect());
          return engine;
      }
  
      @Bean
      public ThymeleafViewResolver thymeleafViewResolver() {
          ThymeleafViewResolver resolver = new ThymeleafViewResolver();
          resolver.setTemplateEngine(templateEngine());
          return resolver;
      }
  }
  </code></pre>
  
  <p>I have the following folder structure</p>
  
  <pre><code>webapp/
  ..WEB-INF/
  ....views/
  ......layouts/
  ........default.html
  ......user
  ........index.html
  </code></pre>
  
  <p>Here is my default.html which is my main layout.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8" /&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&gt;
      &lt;title&gt;Default&lt;/title&gt;
      &lt;link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;header&gt;
          This is a header from default.html
      &lt;/header&gt;
  
      &lt;section layout:fragment="content"&gt;
          &lt;p&gt;Content should go here!&lt;/p&gt;
      &lt;/section&gt;
  
      &lt;footer&gt;
          Footer from default
          &lt;p layout:fragment="custom-footer"&gt;Custom footer here!&lt;/p&gt;
      &lt;/footer&gt;
  
      &lt;!-- scripts --&gt;
      &lt;script src="https://code.jquery.com/jquery-2.1.3.min.js" /&gt;
      &lt;script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
        layout:decorator="layouts/default.html"&gt;
  &lt;head&gt;
      &lt;title&gt;Users&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;section layout:fragment="content"&gt;
      &lt;p&gt;This is a paragraph from content page 1&lt;/p&gt;
  &lt;/section&gt;
  &lt;footer&gt;
      &lt;p layout:fragment="custom-footer"&gt;This is some footer content from content page 1&lt;/p&gt;
  &lt;/footer&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>They are in different folders but the pathing should work unless I'm just missing something really silly.</p>