Skip to content
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

TemplateInputException #321

Open
weissliufeng opened this issue Mar 13, 2024 · 1 comment
Open

TemplateInputException #321

weissliufeng opened this issue Mar 13, 2024 · 1 comment

Comments

@weissliufeng
Copy link

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";
        }
    }
@vigneshsera
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants