springboot 模板可能不存在,也可能不被任何配置的模板解析器访问。

一、如果返回的是jsp页面,或者html,@Controller配合视图解析器InternalResourceViewResolver才行。

需要在application.properties配置文件

spring.thymeleaf.prefix=classpath:/templates/

spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
#spring.thymeleaf.encoding=UTF-8
#spring.thymeleaf.content-type=text/html # ;charset=<encoding> is added

spring.thymeleaf.cache=false

二、如果需要返回JSON,XML或自定义mediaType内容到页面,则需要在对应的方法上加上@ResponseBody注解。

以上两者都会报以下错误

template might not exist or might not be accessible by any of the configured Template Resolvers

认知的海岛越大,无知的海岸线越长
原文地址:https://www.cnblogs.com/bo-gsw/p/9619086.html