title: Thymeleaf: second resolver for SVG in Spring Boot
body: <p>I'm trying to set up a second resolver for SVGs which use thymeleaf attributes, so it needs to be resolved by the template engine within my spring boot application. My implementation so far:  </p>
  
  <p>ThymeleafSvgConfig</p>
  
  <pre><code>@Configuration
  public class ThymeleafSvgConfig {
      @Bean
      public FileTemplateResolver svgTemplateResolver(){
      FileTemplateResolver svgTemplateResolver = new FileTemplateResolver();
      svgTemplateResolver.setPrefix("classpath:/svgtemplates/");
      svgTemplateResolver.setSuffix(".svg");
      svgTemplateResolver.setTemplateMode("XML");
      svgTemplateResolver.setCharacterEncoding("UTF-8");
      svgTemplateResolver.setOrder(0);
  
      return svgTemplateResolver;
      }
  
  }
  </code></pre>
  
  <p>ThymeleafSvgController</p>
  
  <pre><code>@Controller
  public class ThymeleafSvgController {
      @Autowired
      private ServletContext servletContext;
      @Autowired
      private TemplateEngine templateEngine;
  
      //.. logging etc.
  
      @RequestMapping(value = "/getSvg", method = { RequestMethod.GET, RequestMethod.POST })
      public void getSvg(@RequestParam(required = false) String type, HttpServletRequest request, HttpServletResponse response) {
  
      WebContext context = new WebContext(request, response, servletContext, request.getLocale());
      templateEngine.process("test", context, response.getWriter());
      }
  }
  </code></pre>
  
  <p>I read that Spring Boot searches for resolvers automatically and adds them to the engine <a href="https://stackoverflow.com/questions/25610281/spring-boot-sending-emails-using-thymeleaf-as-template-configuration-does-not">[s. this]</a>. So I assumed, that my Config should be enough and that via autowiring I should get the correct template engine.<br>
  But still I receive the same error in my application, when trying to call:<br>
  <code>templateEngine.process("test", context, response.getWriter());</code><br>
  My SVG is saved in /src/main/resources/svgtemplates/test.svg  </p>
  
  <p>Exception:<br>
  <code>org.thymeleaf.exceptions.TemplateInputException: Error resolving template "test", template might not exist or might not be accessible by any of the configured Template Resolvers</code></p>
  
  <p>I'm not sure what I misconfigured, so I need some help with this. Is the FileTemplateResolver the correct class for this? I also tried the ClassLoaderTemplateResolver but it threw the same exception. The standard Thymeleaf Resolver from spring boot works fine, which works with the standard prefix: "classpath:/templates/". So considering that 'templates' and 'svgtemplates' lie in the same folder, my prefix should be correct so far, shouldn't it?<br>
  Maybe someone else sees the flaw.</p>