You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi -
I am trying to use thymeleaf as the template engine for spring boot. I have followed this guide (http://www.thymeleaf.org/springmail.html) and the issue I am running into is that thymeleaf can't seem to resolve the variables set in org.thymeleaf.context.Context when I make the call to process the template.
I get errors like this...
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "user" (email.html:7)
at org.thymeleaf.spring3.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:108)
at org.thymeleaf.standard.expression.VariableExpression.executeVariable(VariableExpression.java:116)
at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:394)
It can be run by cloning the project and "cd" into it and run the following command: "./gradlew run" (without the quotes). Then open your browser and hit http://localhost:8080.
Click the "send email" button and you should see the error on the console.
Also a broader question is what is the best way to easily override the generated "templateEngine" bean created by @EnableAutoConfiguration?
On the "dev" branch of the same project above, I have configured the following beans...
@Bean
public ServletContextTemplateResolver webTemplateResolver() {
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
templateResolver.setPrefix("templates/");
templateResolver.setTemplateMode("HTML5");
templateResolver.setSuffix(".html");
templateResolver.setOrder(2);
templateResolver.setCacheable(true);
return templateResolver;
}
@Bean
public SpringTemplateEngine templateEngine(){
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.addTemplateResolver(emailTemplateResolver());
templateEngine.addTemplateResolver(webTemplateResolver());
return templateEngine;
}
@Bean
public ThymeleafViewResolver thymeleafViewResolver(){
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(templateEngine());
resolver.setCharacterEncoding("UTF-8");
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 20);
return resolver;
}
But navigating to http://localhost:8080 after that configuration reports the following error...
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:958)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:837)
....
The text was updated successfully, but these errors were encountered:
Bumping the version to 2.0.18 or higher resolved the issue.
Thanks!
PS: It will still be helpful to know how to override the default beans e.g. templateEngine defined by @EnableAutoConfiguration. The docs don't do a good job at explaining it. That was the second part this bug ticket.
Hi -
I am trying to use thymeleaf as the template engine for spring boot. I have followed this guide (http://www.thymeleaf.org/springmail.html) and the issue I am running into is that thymeleaf can't seem to resolve the variables set in org.thymeleaf.context.Context when I make the call to process the template.
I get errors like this...
....
I have the sample application here https://github.com/berinle/spring-boot-sample
It can be run by cloning the project and "cd" into it and run the following command: "./gradlew run" (without the quotes). Then open your browser and hit http://localhost:8080.
Click the "send email" button and you should see the error on the console.
Also a broader question is what is the best way to easily override the generated "templateEngine" bean created by @EnableAutoConfiguration?
On the "dev" branch of the same project above, I have configured the following beans...
But navigating to http://localhost:8080 after that configuration reports the following error...
....
The text was updated successfully, but these errors were encountered: