thymeleaf-spring
thymeleaf-spring copied to clipboard
TemplateInputException
Version: spring-boot-starter-thymeleaf 2.0.9.RELEASE
for bugs: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template [layouts/default], 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 [layouts/default], template might not exist or might not be accessible by any of the configured Template Resolvers
sample:
@RequestMapping({"news/{newsId}"}) public String news(Model model, @RequestHeader(name = "name", required = false) String name, @PathVariable("newsId") long newsId) { logger.info("{} read news {}", name, newsId);
try {
NewsDto newsDto = newsService.info2(newsId, name);
model.addAttribute("newsId", newsId);
model.addAttribute("news", newsDto.getInfo());
model.addAttribute("content", newsDto.getContent());
return "news";
} catch (Exception e) {
logger.error("error ", e);
return "redirect:/404";
}
}
Try giving full path of layouts/default template. Hope you would have a class for webconfig with WebMvcConfigurer, ApplicationContextAware interface implementation. There in SpringTemplateEngine set full path in AbstractConfigurationTemplateResolver instead of giving from web-inf.