鍍金池/ 問答/Java/ 學(xué)習(xí)springboot + thymeleaf 遇到的問題

學(xué)習(xí)springboot + thymeleaf 遇到的問題

調(diào)用接口的時(shí)候 項(xiàng)目一直報(bào)錯(cuò): org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/thymeleaf/user", template might not exist or might not be accessible by any of the configured Template Resolvers

請(qǐng)問一般什么問題?

回答
編輯回答
巷尾

如果是使用 spring-boot-starter-thymeleaf,可以添加下列配置在application.properties

spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
2017年10月8日 03:45
編輯回答
陌離殤

對(duì)于springboot,解析頁面時(shí),默認(rèn)從resources 中的templates文件夾下尋找界面解析。

并且對(duì)于使用thymeleaf模板引擎,它要求寫的HTML要嚴(yán)格按照HTML的格式,
如:
單標(biāo)簽一定要有\(zhòng)

<br\>
2017年4月23日 21:27
編輯回答
小眼睛

路徑問題,提示模板文件訪問不到

2018年9月5日 21:30