我正在尝试通过一些春季启动教程。 我在eclipse中导入了这个:https://spring.io/guides/gs/securing-web/
在步骤"创建一个不安全的Web应用程序",我在eclipse中启动它。它启动正常,然后我在浏览器中打开http://localhost:8080,我收到以下错误:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Mar 26 15:15:03 GMT 2016
There was an unexpected error (type=Internal Server Error, status=500).
Error resolving template "home", template might not exist or might not be accessible by any of the configured Template Resolvers
我可以在eclipse的控制台中看到以下错误:
2016-03-26 15:15:03.598 ERROR 4464 --- [nio-8080-exec-1] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-8080-exec-1] Exception processing template "home": Error resolving template "home", template might not exist or might not be accessible by any of the configured Template Resolvers
2016-03-26 15:15:03.629 ERROR 4464 --- [nio-8080-exec-1] 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 "home", 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 "home", template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:246) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
堆栈跟踪更长,如果需要,我可以提供它。
除此之外,我没有从初始状态(在示例中的初始目录内)更改教程的源代码。
有什么想法吗?
答案 0 :(得分:1)
错误解析模板home
错误意味着视图解析程序找不到与此路径匹配的任何模板。
Spring Boot Starter Thymeleaf将配置一个默认的视图解析器,它希望在以下位置找到您的html文件:src/main/resources/templates/
。确保在该位置找到home.html
。如果是,请检查您在发送给我们之前是否有异常。
此致 丹尼尔