New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ThymeleafAutoConfiguration throws "IllegalStateException: Cannot find template location" even when controller method returns ResponseEntity #1827
Comments
I believe that the You can set |
Some were missing, some were named incorrectly. See gh-1827
I notices that we were missing that key from the documentation so I've updated that. |
Thanks for the doc update! I've to add that this error didn't happen if the method returns an object (which will be formatted as JSON) even when templates/ didn't exist. Anyway as you say this is intended behavior. |
I changed my application.properties file only like spring.thymeleaf.check-template-location=false and i customised my TemplateConfiguration class is : @Configuration
public class TemplateConfiguration {
@Bean
public ServletContextTemplateResolver servletContextTemplateResolver() {
ServletContextTemplateResolver servletContextTemplateResolver =
new ServletContextTemplateResolver();
servletContextTemplateResolver.setPrefix("classpath:/views");
servletContextTemplateResolver.setSuffix(".html");
servletContextTemplateResolver.setTemplateMode("HTML5");
return servletContextTemplateResolver;
}
@Bean
public SpringTemplateEngine springTemplateEngine() {
SpringTemplateEngine springTemplateEngine = new SpringTemplateEngine();
springTemplateEngine.setTemplateResolver(servletContextTemplateResolver());
return springTemplateEngine;
}
@Bean
public ThymeleafViewResolver thymeleafViewResolver() {
ThymeleafViewResolver thymeleafViewResolver =
new ThymeleafViewResolver();
thymeleafViewResolver.setTemplateEngine(springTemplateEngine());
thymeleafViewResolver.setOrder(1);
return thymeleafViewResolver;
}
} i still have an error when i send a new request and also i have home.html file in views file:
|
@semihokanpehlivan The property you have configured disables a check for their being a folder named This issue's closed and, from the information you've provided, it's impossible to tell if you've found a bug or your problem's due to user error. I'd recommend posting a question of Stack Overflow with a minimal, complete, verifiable example of the problem. We monitor the |
Copy this in your .pom |
With controller:
And unit test:
ThymeleafAutoConfiguration
throwsIllegalStateException
below, even though the method returnsResponseEntity
so Thymeleaf isn't required at all in this case.The text was updated successfully, but these errors were encountered: