'spring boot and thymeleaf for email only
I have a spring boot application that works correctly.
I need to add a functionality to send emails if certain actions happens.
I have added the thymeleaf code:
@Configuration
public class ThymeleafTemplateConfig {
@Bean
public SpringTemplateEngine springTemplateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.addTemplateResolver(htmlTemplateResolver());
return templateEngine;
}
@Bean
public FileTemplateResolver htmlTemplateResolver() {
FileTemplateResolver emailTemplateResolver = new FileTemplateResolver();
emailTemplateResolver.setPrefix(EMAILS_TEMPLATES_DIRECTORY);
//emailTemplateResolver.setSuffix(".html");
emailTemplateResolver.setTemplateMode("HTML");
emailTemplateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
return emailTemplateResolver;
}
}
and below the code for handling the root url /
@Controller
public class IndexController {
@RequestMapping("/")
public String index() {
//return "main.xhtml";
return "operation.xhtml";
}
}
When I login to my site I redirect to "http://mysiteip/" and I have set as mapping that the "/ " is the operation.xhtml so at the redirection or if I hit "http://mysiteip/" an error occurs.
ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - : - : - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "operation.xhtml", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "operation.xhtml", template might not exist or might not be accessible by any of the configured Template Resolvers
Why the thymeleaf tries to render the view? I want to use thymeleaf only for the email part (send emails with html body).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
