錯誤類型:Exception processing template "xxx": Error resolving template [xxx], template might not exist or might not be accessible by any of the configured Template Resolvers


初學SpringBoot+Thymeleaf,在寫項目時遇到如下錯誤:

[THYMELEAF][http-nio-8081-exec-6]
Exception processing template "xxx": Error resolving template [xxx], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [homepage], template might not exist or might not be accessible by any of the configured Template Resolvers
	at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
	at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]

問題根源:

以下是我在配置文件中寫存放路徑(參見Spring Boot企業級開發教程 黑馬程序員編著)

spring.thymeleaf.prefix= classpath:resources/templates/

解決方法

修改為

spring.thymeleaf.prefix= classpath:/templates/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM