Spring Thymeleaf TemplateResolver error
<p>I am trying to use thymeleaf in spring for localization of text strings. My html templates are in /src/main/resources/templates/</p>

<p>So I have:</p>

<pre><code>@Configuration
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {

    public MvcConfig() {
        super();
    }

    @Override
    public void addViewControllers(final ViewControllerRegistry registry)             {
        super.addViewControllers(registry);
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/sorting").setViewName("sorting");
    }

    @Override
    public void configureDefaultServletHandling(final DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Override
    public void addResourceHandlers(final ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/","/resource/*");
        registry.addResourceHandler("/assets/**")
    .addResourceLocations("classpath:/assets/");
        registry.addResourceHandler("/css/**")
    .addResourceLocations("/css/");
    }


    @Bean
    public ServletContextTemplateResolver templateResolver() {
        ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
        templateResolver.setCacheable(false);
        templateResolver.setPrefix("classpath:/templates/");
        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode("HTML5");
        return templateResolver;
    }

    @Bean
    public SpringTemplateEngine templateEngine() {
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        templateEngine.setTemplateResolver(templateResolver());
        return templateEngine;
    }

    @Bean
    public ViewResolver viewResolver() {
        ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
        viewResolver.setTemplateEngine(templateEngine());
        viewResolver.setCharacterEncoding("UTF-8");
        viewResolver.setOrder(1);
        return viewResolver;
    }
}
</code></pre>

<p>However the template resolver cannot find my templates and I get an error message saying:</p>

<blockquote>
  <p>Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers</p>
</blockquote>

<p>I suspect that this is due to an incorrect path in the line: <code>templateResolver.setPrefix("classpath:/templates/");</code> but am unable to find what prefix should go there.</p>

<p>It seems that most examples put templates under WEB-INF. Is this the recommended way which I should follow as well?</p>